VBA - Zero where Blank

garypea123

Board Regular
Joined
Mar 16, 2020
Messages
221
Office Version
  1. 365
Platform
  1. Windows
Good Morning,

I am sent a file which is similar to the below but I would like to know if there is a quick way that between D3 and J (Rows decrease / increase each day depending on data) that I can run a quick VBA which will add a 0 if the cell is blank?

Thanks,
Gary
Zero.PNG
 

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.
How about using Find and Replace built in function in Excel. No macro needed.
 
Upvote 0
I think its because one week there will be 1000 lines, another week 1200 lines, then 800 lines. I am trying to figure out a way of automating the process so someone has to click a button.

If possible I would like to avoid any manual work at all, because the idea is someone will just a click a button. My issue is that the rest of my macro assumes there are zero's and not blanks.
 
Upvote 0
Try:
VBA Code:
Sub a1159010a()
Dim i As Long
i = Range("B" & Rows.Count).End(xlUp).Row
Range("D3:J" & i).SpecialCells(xlCellTypeBlanks).Value = 0
End Sub

edit: i changed
Range("A" & Rows.Count).End(xlUp).Row
to
Range("B" & Rows.Count).End(xlUp).Row
because col A is empty
 
Upvote 0
Solution

Forum statistics

Threads
1,215,013
Messages
6,122,690
Members
449,092
Latest member
snoom82

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