+ Reply to Thread
Results 1 to 8 of 8

Get rows from another tab

  1. #1
    Registered User
    Join Date
    03-12-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    4

    Get rows from another tab

    Hi all!

    I have a excel-document with two tabs in it.
    Tab2 has 6 columns and 383 rows.
    Column "A", has a number in it.
    The other columns contains various information that's not really important.

    Tab1 concists only of a singel column, column "A", and 62 rows.

    All of the numbers in column "A" in Tab1 are also found somewhere in column "A" in Tab2.

    What I want to do is to single out the numbers from column "A" in Tab1 in column "A" in Tab2.
    The result I'm looking for is a single tab with the 62 rows in Tab1, but now with the other 5 columns of corresponding information that's in Tab2.

    This is something I'll just have to do once so I don't need a advanced function or whatever.
    Maybe I can just search for the Tab1-numbers in Tab2 in someway?
    Then delete all the other rows and save?

    Thanks alot to whoever gives me an answer to this!!!

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Get rows from another tab? Please help me!

    Are the numbers in Tab1 col"A" found only once in Tab2 col"A"?

    EDIT:- Code Added

    If so try

    Please Login or Register  to view this content.

    If no match is found then the cell in "Sheet1" will be highlighted Red


    Change "Sheet1" and "Sheet2" to suit your sheet names
    Last edited by Marcol; 03-12-2010 at 07:53 AM. Reason: Changed code here to save bb space

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Get rows from another tab

    Hi imsims,

    welcome to the forum.

    You can create a new sheet, let's call it Sheet3
    In cell A1 of this sheet, enter

    ='Tab1'!A1

    If your "Tab1" in your actual file has a different name, adjust the formula.

    Copy this cell down to row 62.

    In B1 of your Sheet3 put this formula:

    =vlookup(A1,'Tab2'!$A$1:$A$400,column(B1),false)


    If your "Tab2" in your actual file has a different name, adjust the formula.

    Copy cell B1 across to cell F1
    Copy B1:F1 down to B62:F62

    Now you should have the six columns populated for the 62 codes in column A

    hth

  4. #4
    Registered User
    Join Date
    03-12-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Get rows from another tab? Please help me!

    Thanks for helping me out!!!
    Unfortunately I'm a total noob at this (obviously) and I don't know where to put that code or if I have to exicute it in some way?

  5. #5
    Registered User
    Join Date
    03-12-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Get rows from another tab

    I think I'm getting close with your solution teylyn! Thanks!
    I forgot to mention that the very first row in each tab has titles in them. Should I delete them or change "A1" to "A2" where the info actually starts?

    Also, when I paste this =vlookup(A1,'Tab2'!$A$1:$A$400,column(B1),false) in B1 as you told me, I get an error. I changed Tab2 to Blad2 which is the actual name of the tab. But it still gives me an error.
    When you say "Copy this cell down..", do you mean Ctrl C -> Ctrl V in each cell or just click,drag and expand the cell all the way down to row 62?

    Thanks to both of you!!!

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Get rows from another tab

    In that case go Teylyns' way.

    But if you want to try the code route

    I/. Open the visual basic editor.....Tools>Macro>Visual Basic Editor
    2/. In the editor .......Insert>Module
    3/. Paste all the code in this module
    4/. Change "Sheet1" and "Sheet2" to suit your sheet names
    5/. Close the Editor
    6/. In Excel .......Tools>Macros... There will only be one macro Press Run
    or Alt+f8.....Press Run

    Hope this helps in the future

    P.S.
    Changed code to allow for header
    Last edited by Marcol; 03-12-2010 at 07:51 AM. Reason: P.S. added

  7. #7
    Registered User
    Join Date
    03-12-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Get rows from another tab

    DUDE!
    That macro worked great!
    I appreciat that so much! It's great that there are guys out there like you.
    Thank to teylyn too!
    Take care

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Get rows from another tab

    Happy to have helped

    If your problem is resolved, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody!

+ 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