View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Conditional formatting - based on indentation

here's an idea that may work.

i assumed the accounts were in column A and each child account had 3 spaces more
than the one above it.

Sub test()
Dim ws As Worksheet
Dim i As Long
Dim lastrow As Long
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To lastrow
Select Case InStrRev(ws.Range("A" & i), " ")
Case 0
ws.Range("A" & i).Font.Bold = True
Case 3
ws.Range("A" & i).Font.ColorIndex = 5
ws.Range("A" & i).Font.Bold = False
Case 6
ws.Range("A" & i).Font.ColorIndex = 4
ws.Range("A" & i).Font.Bold = False
End Select
Next
End Sub



--


Gary


wrote in message
...
as per title..

I would like to apply conditional formatting based on the indentation
of text in a cell.

I have a chart of accounts in excel, with a parent-child hierarchy. I
want to format all top-level parents (i.e. no indentation) with bold
(or whatever formatting), then all second-level (i.e. one indent) with
italics.

Is this possible?