我正在使用用户窗体将数据输入工作表。
我想使用复选框来突出显示表格的整行。
示例代码:
Private Sub AddModifyAtRow(ByVal lRow As Long)
cIndex = 0
If CheckBox_NewBuild = True Then cIndex = 37
Dim ws As Worksheet
Set ws = Worksheets("Address")
With ws
'This is the line I'd like to use to highlight row if Checkbox is True
.Cells(lRow, 1).EntireRow.Interior.ColorIndex = cIndex
'Enter the rest of the data from the UserForm into the Table
.Cells(lRow, 1).Value = TxBox_Building.Text
.Cells(lRow, 2).Value = TxBox_BTS.Text
End With
我也尝试过使用这一行:
.Range("Table5[lRow,[#ALL]]").Interior.ColorIndex = cIndex
答案1
你之前是几乎在那里,你尝试了——
[Table5].Rows(lrow).Interior.ColorIndex = cIndex
假设你的lrow
是一个整数。只需将表名调整为你的表即可。