blank cells if loop

dshafique

Board Regular
Joined
Jun 19, 2017
Messages
171
Hi guys, im trying to fill all the blank cells in a selected range with the text "no data". however, im doing a monthly report, and its not necessary for each month to have blank cells. so how can I make an if loop where it checks if blank cells exist in the range, if they do, fill with "no data" otherwise, dont do anything. i have this for filling in blank cells


ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks).Value = "Null"
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try instead

Code:
ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks).Value = "no data"

Looping is not needed as this one-liner does it all at the same time.
 
Last edited:
Upvote 0
So i was looking for an if statement because if there's no blank cells, it gives an error. these are sheets i produce monthly, so sometimes there are no blank cells. basically

if blank cells in range
then fill with "No Data"
else do nothing
 
Upvote 0
Try this mod on Jim's code
Code:
On Error Resume Next
ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks).Value = "no data"
On Error Goto 0
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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