基于查询表中的单元格值使整行加粗的 VBA 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31022300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA Code for Making Entire Rows Bold based on a Cell value in the Query table
提问by Sai
I have a table in the range (G15:AL540) generated through SAP Query . I need to make all the rows Bold , if the Cells in Column L Contains the word "Main Investigation". I did it using Conditional Formatting ( =$L16="Main investigation") and it worked. But I need to write it in VBA , so that this formatting is applied automatically when the Query is refreshed.
我有一个通过 SAP Query 生成的范围 (G15:AL540) 中的表。如果 L 列中的单元格包含“主要调查”一词,我需要将所有行设为 Bold 。我使用条件格式(=$L16="主要调查")做到了,并且奏效了。但是我需要在 VBA 中编写它,以便在刷新查询时自动应用此格式。
Thanks!
谢谢!
采纳答案by 99moorem
This will only work for active sheet, change activesheet to sheets("sheetabc") to reference another sheet
这仅适用于活动工作表,将活动工作表更改为工作表(“sheetabc”)以引用另一张工作表
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

