steveo0707
Board Regular
- Joined
- Mar 4, 2013
- Messages
- 85
- Office Version
- 365
- 2019
- Platform
- Windows
The following is the code I have for moving the blank rows located throughout a table in Excel. When I run the code, it is only moving the 1st and 3rd column blanks down. I have 7 total columns. Any help on this would be much appreciated.
Code:
Public Sub main()
Dim oRange As Range
Set oRange = Worksheets("Sheet1").Range("A3:G28")
MoveData oRange
End Sub
Public Sub MoveData(ByRef oRange As Range)
Dim i As Integer
Dim j As Integer
Dim oMoveRange As Range
For i = 1 To oRange.Rows.Count
If oRange.Value2(i, 1) = "" Then
Set oMoveRange = oRange(i, 1).End(xlDown)
If Intersect(oRange, oMoveRange) Is Nothing Then Exit Sub
For j = 0 To 2 Step 2
oRange(i, j + 1).Value = oMoveRange.Offset(0, j).Value
oMoveRange.Offset(0, j).Value = ""
Next
End If
Next
End Sub