I am trying to automatically enter 0 and 0% values in blank cells in Excel. I have a report in Excel that gets automatically filled up from SAS. After I save this report, I want the blank cells get automatically filled as 0 in numeric columns and 0% in percent columns.
What would the macro or VBA code be for that?
If you just want to add 0 to a blank cell, there are several ways to do that – here’s one using range A1:D10 as an example. Note that if a cell is formatted as percentage, the “%” is automatically appended to the 0. :
Please note that if you are doing this on a large range of cells (actually it’s good practice to do this all the time), you want to make sure you add
Application.ScreenUpdating = Falseat the start of the code andApplication.ScreenUpdating = Trueat the end. That will make it run much faster.