Remove 0 value from specific cells

JustGWN

New Member
Joined
May 3, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello, I followed directions on this issue from an old thread, but I found that the code either deleted my formulas (which I don't want) or it removed all zeros w/ formulas left intact (also don't want). I'm looking to remove zeros only from specific cells and leave others. Thx. If I can add an activecell entry? I tried that already but got an error in the code. New to VBA, not sure what was wrong.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Probably the best way is to use a custom format to hide the zeroes.
See here: Display or hide zero values

I deleted your replies in the other thread, as you should not ask the same question in more than one place on these forums, as per forum rule 12 here: Message Board Rules
 
Upvote 0
Probably the best way is to use a custom format to hide the zeroes.
See here: Display or hide zero values

I deleted your replies in the other thread, as you should not ask the same question in more than one place on these forums, as per forum rule 12 here: Message Board Rules
Yes, I know but once I posted, the site gave me a message that because it was so old, I should create a new thread. Thx.
 
Upvote 0
I'm looking to apply it to specific cells via VBA. Thx.
Its easy enough to apply that custom format to specific cells via VBA, i.e.
VBA Code:
    Range("E13").NumberFormat = "0;-0;;@"
or something like:
VBA Code:
    ActiveCell.NumberFormat = "0;-0;;@"
 
Upvote 0
Solution
Its easy enough to apply that custom format to specific cells via VBA, i.e.
VBA Code:
    Range("E13").NumberFormat = "0;-0;;@"
or something like:
VBA Code:
    ActiveCell.NumberFormat = "0;-0;;@"
Modified to allow for decimals and its perfect! Thx :)
 
Upvote 0
You are welcome.

Note that you can get code like this by using the Macro Recorder and record yourself doing it manually to some cell (applying the custom format).
The Macro Recorder is a great tool for getting snippets of code! Just record yourself performing the steps manually, and see the code it records.
 
Upvote 0
You are welcome.

Note that you can get code like this by using the Macro Recorder and record yourself doing it manually to some cell (applying the custom format).
The Macro Recorder is a great tool for getting snippets of code! Just record yourself performing the steps manually, and see the code it records.
I do usually add VBA by doing that, testing just want I need, then adding to other code. But I didn't think of the formatting as you have provided. Thx again.
 
Upvote 0
I do usually add VBA by doing that, testing just want I need, then adding to other code. But I didn't think of the formatting as you have provided. Thx again.
OK.
I just followed the steps in the link from my first reply with the Macro Recorder turned on. ;)
 
Upvote 0

Forum statistics

Threads
1,225,149
Messages
6,183,194
Members
453,151
Latest member
Lizamaison

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