sandeepkumar4u
New Member
Hello All,
I am new to Excel VBA programming so this might look like a dumb question to most of you. I have 2 columns, one has numbers and other has some text. I would like to indent text based on the numbers in first column. I wrote follwing
This works fine but I would like to loop it instead of putting i=2472. The reason is that I have other similar sheet and the row count can be anything and Instead of writing a row number I would like to loop it so that it stops by itself.
Any help?
EDITED (SirJB7, Luke M)
I am new to Excel VBA programming so this might look like a dumb question to most of you. I have 2 columns, one has numbers and other has some text. I would like to indent text based on the numbers in first column. I wrote follwing
Code:
Sub P_4410()
Dim i As Integer
For i = 2 To 2472
If Cells(i, 1).Value = 2 Then
Cells(i, 2).InsertIndent 1
ElseIf Cells(i, 1).Value = 3 Then
Cells(i, 2).InsertIndent 2
ElseIf Cells(i, 1).Value = 4 Then
Cells(i, 2).InsertIndent 3
End If
Next i
End Sub
This works fine but I would like to loop it instead of putting i=2472. The reason is that I have other similar sheet and the row count can be anything and Instead of writing a row number I would like to loop it so that it stops by itself.
Any help?
EDITED (SirJB7, Luke M)