You are here:

Excel/return blank cells as 0's

Advertisement


Question
Hello all,
I'de like to get zeroes instead of blank spaces in a table of roughly 6,000 codes. The issue is that I run a query weekly that pastes values into 12 columns (for the months of the year) of this table. I would like to get zeroes for the months that do not have any data since that way I could get a pivot tabel to automatically pick up this data.
Thanks

Answer
You could do this manually in a couple of steps, by selecting the whole area, going to menu Edit->Goto->Special->Blanks, typing a 0 and entering it with Crtl+Enter.

You could use a macro like this, that does the same thing.
Sub FillBlanks()
  Range("A1").CurrentRegion.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "0"
End Sub

You may need to change the first part if your range doesn't start on A1, or if the current region doesn't cover the full range that you want to fill.

Hope this helps,
Miguel
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Miguel Zapico

Expertise

I am recycling to Excel 2010, so I am taking an extended leave while I work on keeping myself an expert on this matter.

Experience

I have worked with Excel for the past 12 years, in various environments.

Organizations
NYPC (New York PC users group)

Organizations
NYPC (New York PC users group)

Education/Credentials
MCSE in Windows NT

©2012 About.com, a part of The New York Times Company. All rights reserved.