Replace Blanks in selected Range

grady121

Active Member
Joined
May 27, 2005
Messages
385
Office Version
  1. 2016
Platform
  1. Windows
After entering several values, starting at cell "F10" and continuing down Column "F", there may be empty cells left in between.

I can select all the cells in the variable range, between the top cell "F10" and the last cell with data, but now need to replace all the Blanks left behind in the selected range and format them in a certain manner, using the value of "100" .

What I have so far is:-

Application.Goto Cells(Rows.Count, "F").End(xlUp) ' Finds last Row used in Column F
Range(Selection, Range("F10")).Select ' Select total Range

' The format I need
ActiveCell.FormulaR1C1 = "100"
Selection.Font.Italic = True
Selection.Font.Underline = xlUnderlineStyleSingle
Selection.Font.ColorIndex = 5

But don't know how to achieve my aim.

Any help for a Newbie appreciated.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Code:
Sub test()
On Error Resume Next
Dim c As Range, d As Range
Set d = Range("F10:F" & Range("F" & Rows.Count).End(xlUp).Row)
Set c = d.SpecialCells(xlCellTypeBlanks)
If c Is Nothing Then Exit Sub
With c
    .Value = 100
    .Font.Italic = True
    .Font.Underline = xlUnderlineStyleSingle
    .Font.ColorIndex = 5
End With
End Sub
 
Upvote 0
Already answered, but I will include my code too.
Code:
Sub FillBlanks()
    LastRow = Cells(Rows.Count, "F").End(xlUp).Row
    With Range("F10:F" & LastRow).SpecialCells(xlCellTypeBlanks)
        .Value = 100
        .Font.Italic = True
        .Font.Underline = xlUnderlineStyleSingle
        .Font.ColorIndex = 5
    End With
End Sub
 
Upvote 0
Excellent work guys.
Both options work great.

2 for the price of 1
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,234
Members
452,898
Latest member
Capolavoro009

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