Results 1 to 3 of 3

Thread: Excel Macro Fun Time

  1. Excel Macro Fun Time

    Anyone good at making these things? This isn't for school. I just thought someone here might like doing them and this one is pretty basic but I don't know much about making them.

    Let's say I had a workbook with two sheets. The first sheet is simply a single column of numbers. It's unsorted and must stay that way. The second sheet is a table with several columns, the first column being numbers that resemble the ones on the first sheet. This table is sorted though (by that number). I need a macro that will take the top entry of the column on sheet A, search for that number in Column 1 of sheet B and if it finds it, copies that entire row (every field) next to the number of Column 1 of sheet A. It then checks to see if the next column down has that same number. If it does, it inserts a row under the number on sheet 1 and copies that second one right under the first. It does this until the next row down on sheet B is a new number. Then it goes to the next entry in Column 1 of sheet A and repeats the process until all the numbers on that column have been searched for. If there is no row with a number that matches, it goes down to the next entry (doesn't delete the number).

    So the data post-macro looks like
    34 34 a a a a a a a a
    -- 34 b b b b b b b b
    42
    98 98 c c c c c c c c
    14
    etc


    Anyone want to write this for me? ;p edit=actually, the numbers I keep mentioning aren't going to be numbers...just general strings but they will still be sorted on sheet B
    Last edited by Joust Williams; 04 Aug 2008 at 10:11 PM.

  2. I think I have a two part solution that will work with a bit less messy code, but if anyone still wants to do this, please ;p

  3. Use vlookup.

    In table 1 next to the first number (ie, in B1) write this:
    =VLOOKUP(A1,Sheet2!$A$1:$F$15,2)
    There are 3 parts in this formula. The first part is the reference number (A1).
    The 2nd part is your table in sheet 2.
    The third part is the column to look for.

    So in C1 you would write
    =VLOOKUP(A1,Sheet2!$A$1:$F$15,3)
    and so on and so on, and then you can just have it fill down for the rest of the rows.

    Hope this helps.

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
  •  
Games.com logo