Consulting

Results 1 to 9 of 9

Thread: Big IF Loop Question

  1. #1

    Big IF Loop Question

    I have a big big problem.

    I am wanting to make a macro loop within a loop (or at least years ago when I attempted something like this it was a loop within a loop).

    The thing is (I have attached the 2 files for peoples reference).

    I want the macro to take the '!PRODUCTCODE' column for each cell, go to the data.xls file, find the corresponding 'product code' in the first column.

    Then move to the right and select 'Manufacturer' this would then auto input a slash '/' and then input the cells value to the right Printer.

    If the product code is the same below, like same column but the row down, has the same value as the preceding cell, then this would add a new column after categories and do the same again.

    Repeating the process down the list, how would this be possible please?

    Thanks in advance,
    Jeremy.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    No need for a second loop, just use the Find method. Check it in help.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3

    Thumbs up

    Quote Originally Posted by xld
    No need for a second loop, just use the Find method. Check it in help.
    Ah thanks for that, always seem to go for Loops I know I shouldnt but sometimes its just easier, but I shall have a go at doing it using Find, thanks again, if I get stuck i'll try and make a sample excel file(s) and show you, thanks ever so much again.

    Jeremy.

  4. #4
    What im failing to understand is how would I make it go down one row without it being in a loop though?

    Thats the whol essence of this macro is to get it to look at the numerous same product codes and bring back the values of the corrsponding cells.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Lookup Find in help as suggested.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    I will explain again (see attached):

    in productsExample.xls: What i want it to do is, go down !PRODUCTCODE column find the matching !PRODUCTCODE in dataExample.xls.

    When it finds the corresponding code in the first colum in dataExample.xls

    It then copies the value of column B and C and formats it with the Manufactuer colum value with a prefixed delimiter '/' and then the Printer column value of the corresponding cell.

    It then looks down the !PRODUCTCODE, and if it finds the same code, repeats the process but adds another column into productsExample.xls with the new details of that result.

    The attachement is with this post

  7. #7
    Here's the first file

  8. #8
    and here's the 2nd

  9. #9
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    There's no need for a macro or looping, putting
    =VLOOKUP(RC[-13],[dataExample.xls]Sheet1!C1:C3,2,FALSE) & "/" & VLOOKUP(RC[-13],[dataExample.xls]Sheet1!C1:C3,3,FALSE)

    in productExamples.xls R2C14 and dragging down should do what you want.

Posting Permissions

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