I am trying to create a VBA macro that will look at the information in column "A" and determin how many cells it needs to shift the information right for a BOM.
Current data output
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]0.1
[/TD]
[TD]PN1235[/TD]
[TD]Bike[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]..2[/TD]
[TD]PN2345[/TD]
[TD]Handle Bar[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]...3[/TD]
[TD]PN3456[/TD]
[TD]Metal Frame[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]....4[/TD]
[TD]pn4567[/TD]
[TD]Stainless Steel[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Desired data
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]0.1[/TD]
[TD]PN1235[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]..2[/TD]
[TD]PN2345[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]...3[/TD]
[TD]PN3456[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]....4[/TD]
[TD]4567[/TD]
[/TR]
</tbody>[/TABLE]
My current code is this, but I run into an error when it hits the "rng=" line. I also know the ElseIf statements will be a bit repetative as this can reach 10 levels but this was the easist i could think of.
Current data output
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]0.1
[/TD]
[TD]PN1235[/TD]
[TD]Bike[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]..2[/TD]
[TD]PN2345[/TD]
[TD]Handle Bar[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]...3[/TD]
[TD]PN3456[/TD]
[TD]Metal Frame[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]....4[/TD]
[TD]pn4567[/TD]
[TD]Stainless Steel[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Desired data
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]0.1[/TD]
[TD]PN1235[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]..2[/TD]
[TD]PN2345[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]...3[/TD]
[TD]PN3456[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]....4[/TD]
[TD]4567[/TD]
[/TR]
</tbody>[/TABLE]
My current code is this, but I run into an error when it hits the "rng=" line. I also know the ElseIf statements will be a bit repetative as this can reach 10 levels but this was the easist i could think of.
Code:
Sub GapMacro()
Dim lngRow As Long
Dim lastRow As Long
Dim rng As Range
With ActiveSheet
lngRow = .Cells(2, 1)
lastRow = .Cells(65536, 1).End(xlUp).Row
Do
rng = Range(.Cells(lngRow, 1), .Cells(lngRow, 10))
If .Cells(lngRow, 1) = "0.1" Then
rng.Cut rng.Cells(1).Offset(0, 1)
ElseIf .Cells(lngRow, 1) = "..2" Then
rng.Cut rng.Cells(1).Offset(0, 2)
End If
lngRow = lngRow + 1
Loop Until lngRow = 1 + lastRow
End With
End Sub