+ Reply to Thread
Results 1 to 8 of 8

Lookup table with exceptions?

  1. #1
    Registered User
    Join Date
    02-24-2007
    Posts
    84

    Wink Lookup table with exceptions?

    I'm currently using a lookup table to determine programs to run on a machine, however I have 3 exceptions to this and can not get my code to work.

    Currently the code looks at column D for the type, then column F for the thickness of material. It then calculates the etch time required using the rate (all shown as 1 currently) on the cal_sheet and then rounds this up to a whole number. This is then compared to a second table where the program details are listed against etch times.

    It will make sense when you look at the attached workbook and read the code, honest!

    Currently using the following code:
    Please Login or Register  to view this content.
    This works for everything except my exceptions.

    My proposed new version is:
    Please Login or Register  to view this content.
    But I keep getting an error, highlighting the second LOOKUP.

    Can anyone help please, it probably a simple problem, I just cant see it.

    Thanks,
    Gavin.
    Attached Files Attached Files
    Last edited by gavster; 04-07-2009 at 08:33 AM.

  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: Lookup table with exceptions?

    ",(if(and(D6="B",F6>16,"B Thick",LOOKUP(ROUNDUP
    remove that bracket
    ",if(and(D6="B",F6>16,"B Thick",LOOKUP(ROUNDUP
    i cant see where this formula is supposed to go (well i just chucked it in an empty cell on pad expose)

    edit in fact remove all brackets before the if's
    and close the and arguments with brackets

    then you get
    Please Login or Register  to view this content.
    Last edited by martindwilson; 04-07-2009 at 06:30 AM.
    "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
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Lookup table with exceptions?

    Gavin,

    It's hard to find the code -- for the sake of others it's the final line in the Sheet object Change event, correct ?

    Before getting on to the question...

    -- you will find naming your Modules makes your life easier in the long run (set via Properties window (F4))
    -- remove Modules you don't need (there are lots of empty modules)

    To the question...

    In formula terms:

    Please Login or Register  to view this content.
    Should be (I think)

    Please Login or Register  to view this content.
    You seem to know what you're doing in terms of R1C1 so I have no doubt you can adapt the above to fit in with the relative positioning (based on column F).

  4. #4
    Registered User
    Join Date
    02-24-2007
    Posts
    84

    Re: Lookup table with exceptions?

    Mybe I've not understood your reply properly Martin, but it looks like you are suggesting the following:

    Please Login or Register  to view this content.
    I also tried:
    Please Login or Register  to view this content.
    These still generate the same error, with the following highlighted as the point of error:

    Please Login or Register  to view this content.
    Any other ideas?

    Gavin.

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

    Re: Lookup table with exceptions?

    see what i posted again there is a fixed version there
    you must enclose the "and"
    arguments in brackets
    if(and(D6="B",F6<16,"B Thin",if(
    should be
    if(and(D6="B",F6<16),"B Thin",if(
    and so on

  6. #6
    Registered User
    Join Date
    02-24-2007
    Posts
    84

    Wink Re: Lookup table with exceptions?

    Martin and Donkey,

    Firstly let me apologis for the confusion I have caused.

    Martin you appear top have solved the problem one way using the code I was trying to enter into a sinlge cell on the spreadsheet, whereas Donkey has solved the problem after looking at the code attached to the page I am using. I apologise, I didn't realise the code was actually entering a result into that cell as well.

    This may explain my problems.

    Entering the formula into the cells is the most straightforward for me, as I dont fully understand all the code, as the generous usersd of this site wrote mosty of it for me. But If I enter the formula into the cells it gets overwritten by the code. If I remove the last section of code, the column jump stops working. I am confused.

    Donkey, can you show me how it should look in the code format so that the cells can be left empty?

    Thanks,
    Gavin.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Lookup table with exceptions?

    Gavin, I must confess I'm struggling to follow what it is you want to do ...

    However, before doing anything... remove all lines in the Change event where you have either of:

    Please Login or Register  to view this content.
    Re-insert the False command line once at the very beginning of the Routine (ie pre IF test)
    Re-insert the True command line once at the very end of the Routine prior to the End Sub statement.

    If you want:

    Please Login or Register  to view this content.
    in R1C1 notation then based on the Change event:

    Please Login or Register  to view this content.
    If you opt to paste just the result to Column G (.value = .value) then you will need to ensure the above fires whenever any value that may impact the result alters... so if D changes the above must calculate also not just when F changes as is presently the case.

    Disclaimer: I've not sanity checked or reviewed any other code...

  8. #8
    Registered User
    Join Date
    02-24-2007
    Posts
    84

    Re: Lookup table with exceptions?

    Donkey,

    Thanks for the final reply.

    With your not inconsiderable help I've solved it. The code you supplied needed a slight adjustment to match the columns on the lookup sheet, but other than that its was great.

    Thanks also to Martin who solved the problem, but in a different manner.

    Gavin.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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