+ Reply to Thread
Results 1 to 6 of 6

Macro to clear zeroes

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,888

    Macro to clear zeroes

    I have a workbook that is linked to another workbook

    I have tried to write code to clear all zeroes on the activesheet, but cannot get it to work. Where the data is linked to another workbook and shows a zero is must be cleared , except where there is a zero is shown as a currency i.e. it has an R in front of the zero


    Please Login or Register  to view this content.

    I have attached the source workbook "Data analysis Dept 1.xlsx' as well as the destination workbook containing the macro "Data Analysis All Departments.xlsm"


    Your assistance in resolving this is most appreciated
    Attached Files Attached Files
    Last edited by Howardc1001; 12-19-2019 at 01:25 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Macro to clear zeroes

    Your zeros are derived from formulas in each cell. If you try to use vba to clear the contents, you will wipe out your formulas. The way I would approach the issue is to change the formula to include an If function like"
    Please Login or Register  to view this content.
    any time you are dealing with values created by formula, you have to either use an IF funcion to control what the cell containing the formula shows, or establish a control for the source that the formula evealuates to produce the value shown in the cell with the formula. Trying to control values of cells with formulas by using vba is not recommended.
    Last edited by JLGWhiz; 12-19-2019 at 04:54 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,888

    Re: Macro to clear zeroes

    Thanks for your input and valued solution using a formula

  4. #4
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,888

    Re: Macro to clear zeroes

    Although the formula works perfectly, when I copy the formula to the right and down, the font changes and percentage changes to for eg 0.3448


    How do I retain same format as source workbook ?

  5. #5
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,888

    Re: Macro to clear zeroes

    Have resolved issue. after linking formula with Paste Special Link, I used Paste Special format

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Macro to clear zeroes

    Glad you worked it out.
    regards, JLG

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro to eliminate zeroes if numbers in column match and both sets of columns have zeroes
    By luajambeiro in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-14-2019, 05:07 PM
  2. Clear Column by macro
    By Tefa Tato in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2016, 07:26 AM
  3. Clear merged cell contents in comand button(clear all)
    By mohan_984 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-25-2015, 10:39 AM
  4. [SOLVED] Macro to create csv file delete leading zeroes
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-20-2015, 04:40 AM
  5. Replies: 1
    Last Post: 06-21-2013, 04:05 AM
  6. Add zeroes within dates (NOT leading zeroes)
    By anthony19 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2012, 04:08 PM
  7. Replies: 1
    Last Post: 02-24-2009, 04:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1