Sumeluar
Active Member
- Joined
- Jun 21, 2006
- Messages
- 274
- Office Version
- 365
- 2016
- 2010
- Platform
- Windows
- MacOS
- Mobile
Hello all - I've looking al over for a solution to my dilemma at no avail. After extensive Google search I found the below code which is applying Case to anything on column "C" which is not ideal for my need, the question is: Can I get someone's help to modify the code that only applies to Named Ranges "Sub_Task_1", "Sub_Task_2", "Sub_Task_3" and "Sub_Task_4"? Those four ranges are all on column "C".
Sub Indentation()
Dim ws As Worksheet
Dim i As Long
Dim lastrow As Long
Set ws = Worksheets("2022")
lastrow = ws.Cells(Rows.Count, "C").End(xlUp).Row
For i = 1 To lastrow
Select Case ws.Range("C" & i).IndentLevel
Case 0
ws.Range("C" & i).Font.Bold = False
ws.Range("C" & i).Font.ColorIndex = 1
ws.Range("C" & i).Interior.Color = RGB(255, 255, 255)
Case 1
ws.Range("C" & i).Font.ColorIndex = 3
ws.Range("C" & i).Font.Bold = True
ws.Range("C" & i).Interior.Color = RGB(221, 235, 247)
Case 2
ws.Range("C" & i).Font.ColorIndex = 5
ws.Range("C" & i).Font.Bold = False
ws.Range("C" & i).Interior.Color = RGB(242, 242, 242)
Case 3
ws.Range("C" & i).Font.ColorIndex = 7
ws.Range("C" & i).Font.Bold = False
Case 4
ws.Range("C" & i).Font.ColorIndex = 4
ws.Range("C" & i).Font.Bold = False
End Select
Next
End Sub
Thank you!
Any assistance is greatly appreciated.
Sub Indentation()
Dim ws As Worksheet
Dim i As Long
Dim lastrow As Long
Set ws = Worksheets("2022")
lastrow = ws.Cells(Rows.Count, "C").End(xlUp).Row
For i = 1 To lastrow
Select Case ws.Range("C" & i).IndentLevel
Case 0
ws.Range("C" & i).Font.Bold = False
ws.Range("C" & i).Font.ColorIndex = 1
ws.Range("C" & i).Interior.Color = RGB(255, 255, 255)
Case 1
ws.Range("C" & i).Font.ColorIndex = 3
ws.Range("C" & i).Font.Bold = True
ws.Range("C" & i).Interior.Color = RGB(221, 235, 247)
Case 2
ws.Range("C" & i).Font.ColorIndex = 5
ws.Range("C" & i).Font.Bold = False
ws.Range("C" & i).Interior.Color = RGB(242, 242, 242)
Case 3
ws.Range("C" & i).Font.ColorIndex = 7
ws.Range("C" & i).Font.Bold = False
Case 4
ws.Range("C" & i).Font.ColorIndex = 4
ws.Range("C" & i).Font.Bold = False
End Select
Next
End Sub
Thank you!
Any assistance is greatly appreciated.