Check if cell is empty then bolt cells in row

Buskopan

Board Regular
Joined
Aug 4, 2014
Messages
54
Hello,

need a macro that will check the column A4:A100 and if any blank cells there need to bold the font in that row

Thank you
 
Last edited:
Maybe something like this

Code:
Sub boldrange()
       
    For i = 4 To 100
        If Range("A" & i).Value = "" Then
            Rows(i).EntireRow.Font.Bold = True
        End If
    Next i
        
End Sub
 
Upvote 0
or:
Code:
Public Sub BoldBlankRow()
    Dim rngToCheck  As Excel.Range
    
    Set rngToCheck = Sheets("Sheet1").Range("A4:A1000")
    
    rngToCheck.SpecialCells(xlCellTypeBlanks).EntireRow.Font.Bold = True
End Sub
 
Upvote 0
I'd just add this to Jon's code so it doesn't error if there are no blanks in the range
or:
Code:
Public Sub BoldBlankRow()
    Dim rngToCheck  As Excel.Range
    
    Set rngToCheck = Sheets("Sheet1").Range("A4:A1000")
    
    [COLOR="#0000CD"]On Error Resume Next[/COLOR]
    rngToCheck.SpecialCells(xlCellTypeBlanks).EntireRow.Font.Bold = True
    [COLOR="#0000CD"]On Error GoTo 0[/COLOR]
End Sub
 
Upvote 0
Thank you very much to all! It works.

Can we do bit more ?

Check if cell contains today's date then do the same - bold the raw.
If it not contains the date then put the date (dd.month format) and make the row bold ?
 
Upvote 0
Check if cell contains today's date then do the same - bold the raw.
If it not contains the date then put the date (dd.month format) and make the row bold ?
I think I must be mis-understanding. This appears to me to be saying.

If the cell contains today's date bold the row.
If the cell doesn't contain today's date then put today's date and bold the row.

The result would be all rows have today's date and bold. ??
 
Upvote 0
I think I must be mis-understanding. This appears to me to be saying.

If the cell contains today's date bold the row.
If the cell doesn't contain today's date then put today's date and bold the row.

The result would be all rows have today's date and bold. ??

Yes that is correct. The column have other dates that will remain not bold. Only need to bold the rows that missing date or have todays date. Or we need to insert todays date in empty cells of that column and make the row bold

Sorry for my poor English :)
 
Upvote 0
Only need to bold the rows that missing date or have todays date. Or we need to insert todays date in empty cells of that column and make the row bold
Does this do what you want?
Rich (BB code):
Sub DateAndBold()
  Dim rBlanks As Range
  
  Application.ScreenUpdating = False
  With Range("A1", Range("A" & Rows.Count).End(xlUp))
    .Replace What:=Date, Replacement:="", LookAt:=xlWhole, SearchFormat:=False, ReplaceFormat:=False
    On Error Resume Next
    Set rBlanks = .SpecialCells(xlBlanks)
    On Error GoTo 0
    If Not rBlanks Is Nothing Then
      With rBlanks
        .EntireRow.Font.Bold = True
        .Value = Date
      End With
    End If
  End With
  Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Does this do what you want?
Thank you for patience ) Almost yes. But I need to ignore the empty rows. Range is K9:K128

29oqx3d.jpg
 
Last edited:
Upvote 0
Assuming the entries in column J are actual numbers (not text) and that they are not the result of formulas, maybe ..
Rich (BB code):
Sub DateAndBold()
  Dim rArea As Range, rBlanks As Range
  
  Application.ScreenUpdating = False
  For Each rArea In Range("J9", Range("J" & Rows.Count).End(xlUp)).SpecialCells(xlConstants, xlNumbers).Areas
    With rArea.Offset(, 1)
      .Replace What:=Date, Replacement:="", LookAt:=xlWhole, SearchFormat:=False, ReplaceFormat:=False
      On Error Resume Next
      Set rBlanks = .SpecialCells(xlBlanks)
      On Error GoTo 0
      If Not rBlanks Is Nothing Then
        With rBlanks
          .EntireRow.Font.Bold = True
          .Value = Date
        End With
        Set rBlanks = Nothing
      End If
    End With
  Next rArea
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

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