I have an excel sheet whose data was mixed: for example, the data that should have been in columns AB and AC was instead in columns B and C, but in the row after. I have the following written: they moved data from B and C to AB and AC, respectively:
Dim rCell As Range Dim rRng As Range Set rRng = Sheet1.Range("A:A") i = 1 lastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row For Each rCell In rRng.Cells If rCell.Value = "" Then Range("AB" & i) = rCell.Offset(0, 1).Value rCell.Offset(0, 1).ClearContents End If i = i + 1 If i = lastRow + 1 Then Exit Sub End If Next rCell End Sub
However, it does not fix the problem of the data in the row BELOW the corresponding row, now that they are in the correct columns. I am new to VBA Macros, so I would appreciate any help so that the data is now aligned. I tried to switch the Offset parameter (-1.0), but it does not work.
source share