gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,347
- Office Version
- 365
- Platform
- Windows
I have a column "C" that has numbers in it (numbers between 0 and 15) The column starts at row 7
I want to go down row C and for every row that has a value I want to "Increase Indent" the text in Column B and D the number of time that equals the value In column C of that row.
So in Row 7 if the value in C7 is 2 I want to change the formatting of the content in B and D by Indenting it two times
I'm looking at a very old post where someone posted this code. But I am having trouble understanding it.
I want to go down row C and for every row that has a value I want to "Increase Indent" the text in Column B and D the number of time that equals the value In column C of that row.
So in Row 7 if the value in C7 is 2 I want to change the formatting of the content in B and D by Indenting it two times
I'm looking at a very old post where someone posted this code. But I am having trouble understanding it.
Code:
Function SetIndent(r As Range, ByVal Level As Long) As Variant
' shg 2008
' Sets the indent level of r from 0 to 15 and returns the indent level
Dim cell As Range
SetIndent = IIf(Level < 0, "Min is 0!", IIf(Level > 15, "Max is 15!", Level))
If Level < 0 Then Level = 0 Else If Level > 15 Then Level = 15
For Each cell In r
With cell
If Level - .IndentLevel Then .InsertIndent Level - .IndentLevel
End With
Next cell
End Function