Populating 0's in Null Fields

Dugantrain

Active Member
Joined
Feb 10, 2003
Messages
354
I have a Workbook that I have attached to my Access 2000 database. I have several queries written, all which use the Nz(x,0) function to return a 0 in any Null field and each worksheet in the workbook is attached to a separate query. This workbook has been set to refresh itself on open; however, I keep getting the error message that Nz is unrecognized, when trying to Refresh. Is Nz simply not handled by Excel? If this is the case, I'd like to try to do this on the Excel side; that is, do not alter the Nulls in the Access query, but select an entire column in the Worksheet and set it to autopopulate any Null cells with 0's when Refreshed.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
We'll something does happen when you Export/Import data from Excel to Access.

Like True or False in Excel when imported to Access are converted to 1 and 0 and vise versa.
 
Upvote 0
Hi,

A simple one line macro to replace any null values with zeros is this:-

Code:
ActiveSheet.QueryTables(1).ResultRange.SpecialCells(xlCellTypeBlanks).Value = 0

Does that help?
 
Upvote 0
OK, the code makes sense, where should I put it? In the Workbook code or in each Worksheet where I want 0's populated? And what method/event would this code fall under?
 
Upvote 0
Oh, I see, it's a Macro, so I record it and manually call it whenever I need it. This works fine, but ideally I'd like it to automatically populate certain worksheets with 0's.
 
Upvote 0

Forum statistics

Threads
1,221,498
Messages
6,160,161
Members
451,627
Latest member
WORBY10

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