I have an excel sheet like so:
| A----| B-------| C----| D-------|
| Todd | Sentry |
| Gary | Alquist |
I want a VBA
script that essentially moves the second row diagonally like so:
| A----| B-------| C----| D-------|
| Todd | Sentry | Gary | Alquist |
And I want it to do this for every occurrence there are two rows stacked on top of each other with content, moving the second row diagonally beside the first.
But I keep getting an Object not found
error in the For
loop.
Sub Macro1()
' Macro1 Macro
ColOne = "A"
ColTwo = "B"
ColThree = "C"
For Index = 1 To 1000
Below = Index + 1
If IsEmpty(ColOne + Index.ToString + ":" + ColTwo + Index.ToString) Then
Else
Range(ColOne + Below.ToString + ":" + ColTwo + Below.ToString).Select
Selection.Cut
Range(ColThree + Index.ToString).Select
ActiveSheet.Paste
Index = Index + 2
End If
Next
End Sub