Hey guys,
I can't seem to get a certain code working...
It's the if loop where it stops. Do you guys have any ideas on this?
It should insert rows and add formulas based on some conditions, when there are no more values, the routine needs to stop..
CODE
Sub seperatedumpsconvert()
Dim a As Integer, b As Integer
Rows(6).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Cells(6, 2).Formula = "=A7"
Range("A8").Select
a = ActiveCell.Row
b = ActiveCell.Column
Do
If Cells(a, b).Value = Cells(a - 1, b + 1).Value Then
ElseIf Cells(a, b).Value > Cells(a - 1, b + 1).Value Then
Rows(a).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Cells(a, b).Formula = "=B" & a - 1
Cells(a, b + 1).Formula = "=A" & a + 1
ElseIf Cells(a, b).Value < Cells(a - 1, b + 1).Value Then
Rows(a).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Cells(a, b).Formula = "=B" & a - 1
End If
a = a + 1
Loop Until Cells(a + 1, b).Value = ""
End Sub
Bookmarks