SHARE
TWEET

Insertar Fila despues de un cambio de codigo en columna (EC)

elviscortijo May 8th, 2020 1,526 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub CommandButton1_Click()
  2. Dim tempValueA As String
  3. Dim tempValueB As String
  4. Dim uFila As Integer
  5.  
  6. On Error GoTo Err
  7.  
  8. Application.Goto Hoja1.Range("B3"), True
  9. uFila = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
  10.  
  11. i = 4
  12. Do While i < uFila
  13.     If Sheets("hoja1").Cells(i, 2) <> Empty Then
  14.         tempValueA = Sheets("hoja1").Cells(i - 1, 2).Value
  15.         tempValueB = Sheets("hoja1").Cells(i, 2).Value
  16.         If tempValueA <> tempValueB Then
  17.             Application.Goto Hoja1.Range("B" & i), True
  18.             Selection.EntireRow.Insert
  19.             uFila = uFila + 1
  20.             i = i + 1
  21.         End If
  22.         i = i + 1
  23.     End If
  24. Loop
  25.  
  26. Application.Goto Hoja1.Range("A1"), True
  27.  
  28. Exit Sub
  29.  
  30. Err:
  31. MsgBox ("Error :" & Err.Number & " - " & Err.Description)
  32.  
  33. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top