Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA Code for Making Entire Rows Bold based on a Cell value in the Query table

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.

Thanks!

like image 585
Sai Avatar asked Oct 15 '25 15:10

Sai


1 Answers

This will only work for active sheet, change activesheet to sheets("sheetabc") to reference another 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
like image 118
99moorem Avatar answered Oct 17 '25 06:10

99moorem