Set range of cell = ""

eawachte

New Member
Joined
Jan 14, 2011
Messages
29
I have a database I created in excel. I use VBA to open a file and copy the data then paste it into the database. When i later plot the data and view it i have an issue with "0" values in the excel cells that should be blank, empty, null whatever you want to call it.


This piece of code selects the range i want and then i want to set the range to "" so that "0" doesn't appear when i pull the data up to plot from the database.


Code:


ThisWorkbook.Worksheets("SIM_Database_Entry").Range("B13:B198").Find("").Select
WedgeAddress = ActiveCell.Address
ThisWorkbook.Worksheets("SIM_Database_Entry").Range("X198").Select
CGAddress = ActiveCell.Address
ActiveWorkbook.ActiveSheet.Range(WedgeAddress, CGAddress).Select


'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'up to this point works fine and does what i want it to do
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




Selection.Value = ""


i have tried many options i researched
Selection.Clear
Selection.ClearContents
Selection.Value = ""
Selection.Value = VBNullString
Selection.Value = Null
Selection.Value = Empty


None of these seem to work or do what i want. I also use an IF statement in the same database on a calculated cell and use "" to set values to nothing and this works perfectly with the database and not returning 0...this is empty no value


Thanks for any suggestions!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Select your cells and run the macro:

Code:
Option Explicit
Sub RemoveZero()
    Selection = ""
End Sub
 
Upvote 0
Thanks for the responce nuked, but that still returns 0. If i run the code then go to a cell on the sheet and type "=" i get 0 for the value. If i go to a cell that I have typed IF(statement,"") i get a blank cell.
 
Upvote 0
Sounds very odd. Have you cleared the number formats? Have you got any other code in the workbook?
 
Upvote 0
I haven't cleared the number formats. It is a huge workbook with lots of code. From research i have gathered that excel defaults a cell to 0. That is my issue i think. i need a way to empty that default value of 0 with VBA. I looked back through all my other code (tons of it) and can't find anywhere i have done something similar. I always assign a value to it but its never "".

Im wondering if "" only applies to userforms?
 
Upvote 0
Excel does not default to 0, and "" does not only apply to userforms.

You're probably best uploading the sheet somewhere and posting the link here.
 
Upvote 0
Maybe im not explaining my problem correctly....let me try this explanation

The code does write a "" or blank value to the cell. The issue is i then move this data and call it later. This has me setting another cell = to that cell. This new cell is "0" when i call the blank cell. maybe i need to copy the data into another range in excel and just use =IF(RC=0,"") this will result in "" or a blank when i try to use the cell later...
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,820
Members
449,469
Latest member
Kingwi11y

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