+ Reply to Thread
Results 1 to 6 of 6

Macro to set Y for a 0 value works where is not intended to

  1. #1
    Registered User
    Join Date
    05-06-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Macro to set Y for a 0 value works where is not intended to

    Hello guys,

    So i have a huge spreadsheet and a huge macro.
    It's basically a huge stocklist. Part of the code i'm using is :

    Please Login or Register  to view this content.
    That basically means that if i have 0 stock , then delivery time is 0,
    And if stock is different from 0, delivery time should be 5.

    Problem is, the code works and sets 0 for stocks that are 0, but ALSO for stocks that include 0. So that means that if i have 205, 190 or 2803 units in stock, the macro will see that 0 there and will set 0 delivery date.
    Any idea how to fix this ?


    Also, after this stocklist is copied on a different sheet, i use the below code to set all the lines that had 0 as delivery time as Y on a different column (basically it says it's 0 stock, so it's a YES for Out of stock)
    Please Login or Register  to view this content.
    Problem is that it displays Y where it should, and 0 elsewhere. Is there a way i can make it to display only Y for true , and nothing for false?

    Any help would be greatly appreciated.
    Thanks,

    Alex

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Macro to set Y for a 0 value works where is not intended to

    why are you searching for 0? is 0 text?
    why not like this
    Range("L:L").FormulaR1C1 = "=IF(RC[-7]=0,0,IF(RC[-17]=0,0,5))"
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    05-06-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Macro to set Y for a 0 value works where is not intended to

    That's a nicer and shorter way of putting it.
    Sadly, still the same issue.

    "2093 Y"
    IT still does not ignore the 0 inside ...

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Macro to set Y for a 0 value works where is not intended to

    search for y first? what is in the 2 cells

  5. #5
    Registered User
    Join Date
    05-06-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Macro to set Y for a 0 value works where is not intended to

    Thing is, i got a sheet where i sort things out and i set delivery time to 5 or 0
    Then everything is copied to a new sheet, where there is the additional column for Out of Stock (Y or blank).

    basically the macro just looks if there's a 0 in Col J (delivery time).
    That piece of code seems the work fine.

    just the code that displays 5 or 0 does not work properly...

  6. #6
    Registered User
    Join Date
    05-06-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Macro to set Y for a 0 value works where is not intended to

    morning guys,

    Any more ideas / help out here ?

    Thanks,

+ 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. Why adding button & assigning macro doesnt work as intended
    By SoulPrisoner in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2013, 05:09 PM
  2. Macro causing Excel to freeze - intended to hide cells with zero value
    By ParkingExcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2012, 02:11 AM
  3. [SOLVED] SOLVED: Print Macro Not Working As Intended
    By boldcode in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2011, 09:22 AM
  4. [SOLVED] Macro now opens up VBA editor - not intended
    By excelnut1954 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-13-2006, 01:40 PM
  5. [SOLVED] macro not working as intended
    By Michael A in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-06-2005, 10:06 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