Simple VB Script - Part 2

G

Graeme

Ok, I figured our how to do my indenting per line,

Range("A23:I23").Select
Selection.InsertIndent (ActiveCell.Value)
Range("A24:I24").Select
Selection.InsertIndent (ActiveCell.Value)
Range("A25:I25").Select
Selection.InsertIndent (ActiveCell.Value)
Range("A26:I26").Select
Selection.InsertIndent (ActiveCell.Value)

Is there a way to simplify the code to check row 1 for a
value, if there is a value then perform the indent. Move
to the next line and perform the operation until it comes
to a blank row, then it stops?

Sorry for the newbie questions,

Thanks,
Graeme
 
B

Bob Phillips

Graeme,

Try This

For i = 25 to Cells(Rows.Count,"A").End(xlUp).Row
If Range("A" & i).Value <>"" Then
Range("A" & i & ":I" & i).InsertIndent Range("A" & i).Value
End If
Next i

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
G

Graeme

Thanks Bob!

That works perfect!

Graeme

-----Original Message-----
Graeme,

Try This

For i = 25 to Cells(Rows.Count,"A").End(xlUp).Row
If Range("A" & i).Value <>"" Then
Range("A" & i & ":I" & i).InsertIndent Range ("A" & i).Value
End If
Next i

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top