Conditional formating macro: If one cell is blank then nest two bold and Filled

tweek

Board Regular
Joined
Jun 16, 2006
Messages
104
Hi.

Can someone help me with this one?

I have a long list of numbers in columns A to F

What I want to do is to make a macro that makes cell B and C turn bold and filled with some color if cell D in the same line is blank. And make this macro run through all my lines ( a few thousand).

Is this possible ?

Thank you! :)
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi Tweek - welcome to the board!

If all of the cells in column A will for sure have data, then you can use code to find the last row, and then have your code loop thru each row looking for an empty cell in column D.

See if this will do what you want.....

Code:
Sub CheckForBlanks()

Dim wb As Workbook
Dim ws As Worksheet
Dim LastRow As Long

Set wb = ThisWorkbook
Set ws = wb.Worksheets("Sheet1") 'change name if applicable
LastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row

For a = 2 To LastRow 'assuming row 1 is header
    If IsEmpty(ws.Cells(a, 4)) Then 'check column D for blank cell
        ws.Cells(a, 2).Font.Bold = True 'bold column B
        ws.Cells(a, 2).Interior.ColorIndex = 4 'color column B green
        ws.Cells(a, 3).Font.Bold = True 'bold column B
        ws.Cells(a, 3).Interior.ColorIndex = 5 'color column C blue
    End If
Next a
 
End Sub
 
Upvote 0
Couldn't you just do this using standard conditional formatting?

Select the relevant rows in columns B & C, goto Format>conditional formatting..., select formula is and enter this changing the 1 to the row where the data is

=$D1=""

Now format as required.
 
Upvote 0
Hi guys, Thank you VERY much!

Both methods work for me.

Decklun, your code is exactly what I was hoping for!

thank you again! :D
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,962
Latest member
Fenes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top