vba fill in blank cells with a value

dshafique

Board Regular
Joined
Jun 19, 2017
Messages
171
Hey guys, I needed some help in figuring out a way to loop a certain function in excel.
I have a table with 4 columns, and what I want to do is fill in all the blanks with "Not given"
I was going about it by manually filtering each column for blanks, and filling them with "not given" however, after the second column when I tried filtering the last column, there weren't any blanks. typically it would be alright, but this is going to be a template for future reports so there might be blanks in that column

i wanted something like the pseudo code:

IF no blanks, then do nothing, else filter for blanks, and fill cells with "Not Given"

any and all resolve would be greatly appreciated!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Code:
Function FillTable(ByRef rTable As Range)
'Example on using function within VBA:
'Call FillTable(Range("Table2"))
Dim cel As Range


For Each cel In rTable.Cells
    If IsEmpty(cel) Then cel.Value = "Not given"
Next cel
End Function
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,608
Members
449,174
Latest member
ExcelfromGermany

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