
Eliminar Fila
Publicado por ottneiber (2 intervenciones) el 08/02/2018 14:07:52
Buenos Dias, Estoy haciendo una macro para Excel, el cual me lea el dato y me borre la fila en la que esta ese dato, me funciona para producto pero aqui tengo un error, me llega a la celda, pero no me logra borrar la fila, Help . pls.
He allí la macro: a ver si ven algo que estoy obviando.
He allí la macro: a ver si ven algo que estoy obviando.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Private Sub cmdEliminarP_Click()
Dim Hoja As String
Dim NombrePersona As String
Dim Respuesta As Variant
On Error Resume Next
Application.ScreenUpdating = False
NombrePersona = txtNombrePers.Value
Respuesta = MsgBox("Confirmas la eliminación de " & NombrePersona & "?", vbYesNo, "Eliminación de la Persona")
If Respuesta = vbYes Then
Application.DisplayAlerts = False
Hoja = cmbCodigoPers.Value
If Hoja = "" Then
MsgBox "Debes seleccionar un código de la Persona a eliminar", vbInformation
Exit Sub
End If
Hoja3.Visible = xlSheetVisible
Hoja3.Select
Range("A2").Select
I[b]f ActiveCell.Value <> "" Then
While ActiveCell.Value <> Hoja
ActiveCell.Offset(1, 0).Select
Wend
linea = ActiveCell.Value
'Rows("linea").Select
Rows("" & linea & " : " & linea & "").Select
'Range(linea).EntireRow.Delete
' Selection.Delete shift:=xlUp
Selection.EntireRow.Delete ' intento de varias maneras pero no me borra la bendita fila...
MsgBox "Se ha eliminado a " & NombrePersona & " con código " & Hoja & ".", vbInformation
Else
MsgBox "No hay personas en la Base de Datos", vbExclamation
Hoja3.Visible = xlSheetHidden
Hoja1.Select
Exit Sub
End If
Application.DisplayAlerts = True
Else
Exit Sub
End If
Hoja3.Visible = xlSheetHidden
Hoja1.Select
Range("C7").Select
Range("C7").ClearContents
Application.ScreenUpdating = True
Unload Me
End Sub
Valora esta pregunta


0