Darren Smith
Well-known Member
- Joined
- Nov 23, 2020
- Messages
- 631
- Office Version
- 2019
- Platform
- Windows
Is there a easier way to accomplish the same result.
The idea is to put color in lines above the filled in excel spreadsheet rows in specified ranges.
Specified by combobox choose.
The idea is to put color in lines above the filled in excel spreadsheet rows in specified ranges.
Specified by combobox choose.
VBA Code:
Private Sub Add_Break_Lines_Click()
Dim Com As ComboBox
Dim ws As Worksheet
Dim wb As Workbook
Set wb = Workbooks("Automated Cardworker.xlsm")
Set ws = wb.Sheets("Job Card Master")
Set Com = Me.Add_Break_Lines
With ws
Select Case Com.Value
Case ("Break Lines 1 Page Job Card")
Color .Range("A13:Q61")
Case ("Break Lines 2 Page Job Card")
Color .Range("A13:Q61")
Color .Range("A66:Q120")
Case ("Break Lines 3 Page Job Card")
Color .Range("A13:Q61")
Color .Range("A66:Q122")
Color .Range("A127:Q178")
Case ("Break Lines 4 Page Job Card")
Color .Range("A13:Q61")
Color .Range("A66:Q122")
Color .Range("A127:Q183")
Color .Range("A188:Q244")
Case ("Break Lines 5 Page Job Card")
Color .Range("A13:Q61")
Color .Range("A66:Q122")
Color .Range("A127:Q183")
Color .Range("A188:Q244")
Color .Range("A249:Q299")
End Select
End With
End Sub
Function Color(rng As Range)
Dim row As Range
Dim EmptyRowNum As Integer
For i = 1 To rng.Rows.Count
Set row = rng.Rows(i)
If WorksheetFunction.CountA(row) = 0 Then
EmptyRowNum = EmptyRowNum + 1
End If
If EmptyRowNum = 2 Then
EmptyRowNum = 0
row.Interior.ColorIndex = 6
End If
Next i
End Function