You have a naming error, sheet
vs ws
: Dim sheet as Worksheet
in the Color()
function but then you set ws = ...
.
Anyway, it is misplaced, you need to move it to Fill_Color_Click()
:
Private Sub Fill_Color_Click()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Job Card Master")
so that the references to the ranges make sense.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…