VBA 根据查询中的单元格值将整行加粗的代码 table
VBA Code for Making Entire Rows Bold based on a Cell value in the Query table
我在通过 SAP 查询生成的范围 (G15:AL540
) 中有一个 table。如果列 L
中的单元格包含“主要调查”一词,我需要将所有行设为粗体。我使用条件格式 (=$L16="Main investigation"
) 完成了它并且它起作用了。但是我需要把它写在 VBA 中,以便在刷新查询时自动应用这种格式。
谢谢!
这仅适用于 active sheet,将 activesheet 更改为 sheets("sheetabc") 以引用另一个 sheet
Sub test()
With ActiveSheet
For Each cell In .Range("G15:" & .Range("G15").End(xlDown).Address)
If .Cells(cell.Row, 12).Value = "Main investigation" Then
cell.EntireRow.Font.Bold = True
End If
Next
End With
End Sub
我在通过 SAP 查询生成的范围 (G15:AL540
) 中有一个 table。如果列 L
中的单元格包含“主要调查”一词,我需要将所有行设为粗体。我使用条件格式 (=$L16="Main investigation"
) 完成了它并且它起作用了。但是我需要把它写在 VBA 中,以便在刷新查询时自动应用这种格式。
谢谢!
这仅适用于 active sheet,将 activesheet 更改为 sheets("sheetabc") 以引用另一个 sheet
Sub test()
With ActiveSheet
For Each cell In .Range("G15:" & .Range("G15").End(xlDown).Address)
If .Cells(cell.Row, 12).Value = "Main investigation" Then
cell.EntireRow.Font.Bold = True
End If
Next
End With
End Sub