I'm having a problem with a sub for shading a row. I started by recording a macro, then generalizing it as below:
vba gives a runtime error 1004 indicating the range method failed. The calling routine gets the worksheet object by Worksheets(strSheetName), so I'm a little stumped. The other arguments are also correct and it makes no difference if I declare the first parameter as ByRef.
thanks in advance!
Sub ShadeRow(aSheet As Worksheet, row As Long, nCols As Integer, blueFlag As Boolean)
'
' Shade iRow X cols blue or green
'
With aSheet.Range(Cells(row, 1), Cells(row, nCols)).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
If (blueFlag) Then
.ThemeColor = xlThemeColorAccent1
Else
.ThemeColor = xlThemeColorAccent6
End If
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
End Sub
vba gives a runtime error 1004 indicating the range method failed. The calling routine gets the worksheet object by Worksheets(strSheetName), so I'm a little stumped. The other arguments are also correct and it makes no difference if I declare the first parameter as ByRef.
thanks in advance!