Code was working until I tried to call Sub cbMaint_Click for me another Sub cbMaint_btn. Now I am geting a 50290 error on red line. Any thoughts?
How can I streamline this code?
Sub cbMaint_btn()
Dim MaintItems As Range
Set MaintItems = Range("B9:B19")
Call cbMaint_Click(MaintItems)
End Sub
Sub cbMaint_Click(Maintlist As Range)
Dim cell As Range
If Range("A1").Value = "D" Or ActiveSheet.Shapes("cbMaint").ControlFormat.Value = xlOn Then
Range("F9").Interior.ColorIndex = 6
For Each cell In Worksheets("ROM").Range(Maintlist)
'enable Complexity column
cell.Offset(0, 1).Interior.ColorIndex = 6 'yellow
cell.Offset(0, 1).Font.ColorIndex = xlColorIndexAutomatic
cell.Font.ColorIndex = xlColorIndexAutomatic 'black
cell.Offset(0, 1).Value = "None"
cell.Offset(0, 1).Validation.InCellDropdown = True
cell.Offset(0, 1).Validation.ShowError = True
'enable Hours column
cell.Offset(0, 2).Interior.ColorIndex = xlColorIndexNone 'no color
cell.Offset(0, 2).Font.ColorIndex = xlColorIndexAutomatic
"
Next cell
Else
For Each cell In Worksheets("ROM").Range(Maintlist)
cell.Offset(0, 1).Interior.ColorIndex = xlColorIndexNone 'no color
cell.Offset(0, 1).Font.ColorIndex = 15
cell.Font.ColorIndex = 15 'light gray
cell.Offset(0, 1).Value = "None"
cell.Offset(0, 1).Validation.InCellDropdown = False
cell.Offset(0, 1).Validation.ShowError = False
'disable Hours column
cell.Offset(0, 2).Font.ColorIndex = 15 'light gray
Next cell
End If
End Sub
How can I streamline this code?
Sub cbMaint_btn()
Dim MaintItems As Range
Set MaintItems = Range("B9:B19")
Call cbMaint_Click(MaintItems)
End Sub
Sub cbMaint_Click(Maintlist As Range)
Dim cell As Range
If Range("A1").Value = "D" Or ActiveSheet.Shapes("cbMaint").ControlFormat.Value = xlOn Then
Range("F9").Interior.ColorIndex = 6
For Each cell In Worksheets("ROM").Range(Maintlist)
'enable Complexity column
cell.Offset(0, 1).Interior.ColorIndex = 6 'yellow
cell.Offset(0, 1).Font.ColorIndex = xlColorIndexAutomatic
cell.Font.ColorIndex = xlColorIndexAutomatic 'black
cell.Offset(0, 1).Value = "None"
cell.Offset(0, 1).Validation.InCellDropdown = True
cell.Offset(0, 1).Validation.ShowError = True
'enable Hours column
cell.Offset(0, 2).Interior.ColorIndex = xlColorIndexNone 'no color
cell.Offset(0, 2).Font.ColorIndex = xlColorIndexAutomatic
"
Next cell
Else
For Each cell In Worksheets("ROM").Range(Maintlist)
cell.Offset(0, 1).Interior.ColorIndex = xlColorIndexNone 'no color
cell.Offset(0, 1).Font.ColorIndex = 15
cell.Font.ColorIndex = 15 'light gray
cell.Offset(0, 1).Value = "None"
cell.Offset(0, 1).Validation.InCellDropdown = False
cell.Offset(0, 1).Validation.ShowError = False
'disable Hours column
cell.Offset(0, 2).Font.ColorIndex = 15 'light gray
Next cell
End If
End Sub