ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple VB Script - Part 2 (https://www.excelbanter.com/excel-programming/289990-simple-vbulletin-script-part-2-a.html)

Graeme[_3_]

Simple VB Script - Part 2
 
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

Bob Phillips[_6_]

Simple VB Script - Part 2
 
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)

"Graeme" wrote in message
...
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




Graeme[_3_]

Simple VB Script - Part 2
 
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)

"Graeme" wrote in

message
...
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



.



All times are GMT +1. The time now is 11:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com