+ Reply to Thread
Results 1 to 7 of 7

replace range cells <> 0 with 0

  1. #1
    Registered User
    Join Date
    04-07-2014
    Location
    Orlando
    MS-Off Ver
    Excel 2003
    Posts
    18

    replace range cells <> 0 with 0

    I have a range of cells a35:a243

    If the cells contain any number other than 0, replace with 0

    I have a sheet that I select a quanity of product a35:a243, and I start a new quote, I want to set all quanties to 0 Zero

    when the quanity <> 0, I want to set that cell to 0

    Note: Within the range I have charactor fields that I want to leave as is, Only want to effect numbers <> 0 to set them to 0

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: replace range cells <> 0 with 0

    See next code
    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: replace range cells <> 0 with 0

    For the fun another one faster

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-07-2014
    Location
    Orlando
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: replace range cells <> 0 with 0

    When I use

    Sub ResetVal2()
    Const RgAdd = "A35:A243"
    Dim WkRg As Range, Rg As Range
    Set WkRg = Range(RgAdd)
    With WkRg
    .Parent.AutoFilterMode = False
    .AutoFilter Field:=1, Criteria1:=">0"
    .SpecialCells(xlCellTypeVisible).Cells = 0
    .Parent.AutoFilterMode = False
    End With
    End Sub

    It eliminates my filter button on B33 (set to filter <non blanks> from b34:v243
    I use this filter to filter in quantities over the value of 0

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: replace range cells <> 0 with 0

    It eliminates my filter button on B33
    Yes it is a limit of this macro as it's using filter ... it was just a trial ..!

  6. #6
    Registered User
    Join Date
    04-07-2014
    Location
    Orlando
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: replace range cells <> 0 with 0

    Thank you very much

  7. #7
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: replace range cells <> 0 with 0

    You're welcome it was a pleasure.
    BTW You should know that posting code, needs to use code tags, see forum rules

+ 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. Replace text in a range of cells
    By nightoul in forum Excel General
    Replies: 2
    Last Post: 11-08-2019, 02:45 PM
  2. [SOLVED] How to replace a cell value in a large range of cells?
    By herbie226 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 04-13-2014, 02:12 AM
  3. [SOLVED] Replace empty cells with zero in a range
    By Snoopy2003 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2012, 06:35 PM
  4. Macro to look through cells in range and replace
    By uncleslinky in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-21-2011, 04:06 AM
  5. Replace range of cells with a formula
    By dcgrove in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-22-2010, 07:48 PM
  6. select range of cells and replace
    By antony moseley in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-15-2008, 08:06 AM
  7. [SOLVED] How can I replace a range of blank cells with a 0
    By Replacing blank cells in forum Excel General
    Replies: 1
    Last Post: 08-18-2005, 08:05 PM

Tags for this Thread

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