Rellenar Series con VB de excel
Hola a todos los amigos nuevamente yo por aquí resulta que tengo este código:
Sub BuscarHoja1()
'Por.DAM
'Borrar Datos antiguos
'---------------------------------
ActiveSheet.Unprotect Password:="987"
'---------------------------------
Sheets("Informe").Select
Range("A2:J30").Select
Selection.ClearContents
Selection.ClearComments
Selection.ClearFormats
Range("A2").Select
'---------------------------------
Set h1 = Sheets("Informe")
hoja = InputBox("Digite el número: ", "HOJA")
For Each h In Sheets
If h.Name = hoja Then existe = True
Next
If existe Then
Set h2 = Sheets(hoja)
Sheets(hoja).Unprotect Password:="987"
u1 = h1.Range("M" & Rows.Count).End(xlUp).Row + 1
h2.AutoFilterMode = False
u2 = h2.Range("M" & Rows.Count).End(xlUp).Row
h2.Range("B5:P" & u2).AutoFilter Field:=12, Criteria1:="Parada"
If h2.Range("M" & Rows.Count).End(xlUp).Row > 1 Then ' Tratar de colocar desde aqui el else
h2.Range("B6:D" & u2 & ",M6:O" & u2).SpecialCells(xlCellTypeVisible).Copy _
h1.Range("A" & h1.Range("A" & Rows.Count).End(xlUp).Row + 1)
Range("A2").Select
If Cells(3, 1).Value = "" Then
Cells(2, 1) = 1
Else
Range("A2", Selection.End(xlDown)).Select
Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1, Trend:=False
'Range("A2").Select
End If
Range("A2").Select
MsgBox "Registros ''disponibles'' copiados", vbInformation, "COPIAR DATOS"
Else
MsgBox "Registros ''Ningun Equipo'' Con Falla Mecanica", vbInformation, "FELICITACIONES"
End If
Else
MsgBox "El número de hoja no existe", vbInformation, "COPIAR DATOS"
Exit Sub
End If
h2.AutoFilterMode = False
Sheets(hoja).Protect Password:="987"
End Suby cuando lo ejecuto con F8 me ordena los números correctamente vale decir aplica el enumerado correctamente pero cuando lo ejecuto desde la hoja me sale cualquier cosa.
por favor me pueden ayudar a resolverlo ya cambie de muchas formas el código pero solo funciona correctamente con F8.
Gracias
Roberto
1 respuesta
Respuesta de Dante Amor
1