Code for making empy cells zero - issues.

Nygie

Board Regular
Joined
Apr 15, 2015
Messages
50
Morning all.
I found the below code to fill a selected range that has empty cells amongst the data to fill the blank cells with whatever input into the resulting pop up box, in this case zero.
It works on part of the worksheet but not on the other, I cannot understand why it will not work on part of the worksheet, the whole of which is formatted the same. You can manually add data to the empty cells?? It works on columns A,B & C or if I inset a new column in the middle of my data it works in that also. The data was pasted into the worksheet A,B & C are not original to this data i.e. inserted after the fact.
I'm bamboozled as to why this is.


[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Sub FillEmptyBlankCellWithValue()
Dim cell As Range
Dim InputValue As Integer
On Error Resume Next
InputValue = InputBox("Enter value that will fill empty cells in selection", _
"Fill Empty Cells")
For Each cell In Selection
If IsEmpty(cell) Then
cell.Value = InputValue
End If
Next
End Sub[/FONT]
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
That wont care where the selection is, presuming its a range of cells, so can only presume that the isempty test returns false.
 
Upvote 0
Thanks Steve, true enough if I select a range and use "clear contents" first it works. Looks like the is a space in all the empty cells Arrgghhh
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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