Jump to content

GILDARDO GONZALO LUNA GARC

Members
  • Content Count

    7
  • Joined

  • Last visited

Reputation Activity

  1. Like
    GILDARDO GONZALO LUNA GARC reacted to qwerty123 in Cuando una macro no encuentra un nombre como hacer para que siga ejecutando   
    Hola.
    Antes de "Cells.Find..."  escribe:  "On Error Resume Next" para evitar que se detenga por el error.
    Prueba el siguiente código. Lo he retocado un poco porque con el original, supongo que lo obtendrías de la grabadora de macros, me estaba perdiendo.
     
    Private Sub NuevoCambioEstado() Dim rTotal As Range Dim sCab1(1 To 11) As String Dim iCab As Integer Dim lFila As Long With Range("B1:B5") .Copy With .Offset(, 1) .PasteSpecial xlPasteAll .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom With .Font .Size = 12 .Bold = True End With For lFila = 1 To .Rows.Count .Cells(lFila, 1) = Trim(.Cells(lFila, 1)) Next .Resize(, 5).Merge True End With End With Columns("B:B").Clear With Columns("C:C") .ColumnWidth = 60 .IndentLevel = 1 End With With Columns("D:G") .ColumnWidth = 15 .NumberFormat = "#,##0" End With With Range("C8:G8") .BorderAround LineStyle:=xlDouble, Weight:=xlThick .Borders(xlInsideVertical).LineStyle = xlContinuous .VerticalAlignment = xlCenter .HorizontalAlignment = xlCenter .WrapText = True With .Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent1 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With .Font.Bold = True End With With Range([C10], Cells(Rows.Count, 3).End(xlUp)).Resize(, 5) .BorderAround LineStyle:=xlDouble, Weight:=xlThick .Borders(xlInsideHorizontal).LineStyle = xlContinuous .Borders(xlInsideVertical).LineStyle = xlContinuous For lFila = 1 To .Rows.Count .Cells(lFila, 1) = Trim(.Cells(lFila, 1)) Next sCab1(1) = "ACTIVO A CORTO PLAZO" sCab1(2) = "ACTIVO A LARGO PLAZO" sCab1(3) = "PASIVO A CORTO PLAZO" sCab1(4) = "CAPITAL" sCab1(5) = "TOTAL ACTIVO A CORTO PLAZO :" sCab1(6) = "TOTAL ACTIVO A LARGO PLAZO :" sCab1(7) = "TOTAL PASIVO A CORTO PLAZO :" sCab1(8) = "TOTAL ACTIVO :" sCab1(9) = "TOTAL PASIVO :" sCab1(10) = "TOTAL CAPITAL :" sCab1(11) = "TOTAL PASIVO + CAPITAL :" For iCab = 1 To UBound(sCab1) Set rTotal = Nothing On Error Resume Next Set rTotal = .Cells.Find(What:=sCab1(iCab), LookAt:=xlWhole) On Error GoTo 0 If Not rTotal Is Nothing Then With rTotal.Resize(, 5) .Font.Bold = True If iCab > 4 Then .BorderAround LineStyle:=xlDouble, Weight:=xlThick With .Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent1 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With .IndentLevel = 2 - (iCab > 7) End If End With End If Next End With MsgBox "Estado de Cambios Generado", vbInformation, "TERMINADO" End Sub Un saludo.
×
×
  • Create New...

Important Information

Privacy Policy