Link to home
Start Free TrialLog in
Avatar of ki re
ki re

asked on

Indent Based On Corresponding Cell content

Hello Experts,

I am trying to write  vba code to auto indent cells based on cell content.
User generated imageAsm Part: indent by 2
Operation: Indent by 3
Something like that
Avatar of Roy Cox
Roy Cox
Flag of United Kingdom of Great Britain and Northern Ireland image

There's no Indent in Excel Here's a quick workaround. Uses the WorkSheet Change event
INDENT.xlsm
Avatar of ki re
ki re

ASKER

Private Sub Worksheet_Change(ByVal Target As Range)
     
    If Not Intersect(Range("A:A"), Target) Is Nothing Then
        If IsNumeric(Target.Value) Then
            If Target.Value >= 0 Then
                Target.Offset(0, 1).IndentLevel = Target.Value
            End If
        End If
    End If
End Sub

Instead of target value here i want excel can recognize the content
Can you attach the workbook an I'll take a look
Your cell references are wrong. I need to go out but I'll look at this later for you
Avatar of ki re

ASKER

Thank you
ASKER CERTIFIED SOLUTION
Avatar of Roy Cox
Roy Cox
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The code that I provided works when testing