+ Reply to Thread
Results 1 to 9 of 9

Thread: get name from a different worksheet using and id field

  1. #1
    Registered User
    Join Date
    09-08-2008
    Location
    india
    Posts
    8

    get name from a different worksheet using and id field

    Hi,
    I need to get the value of a column from a different worksheet in the same excel file.

    Sheet1
    Col1 Col2 CID Cname Col5

    Sheet2
    ID Name

    I need to populate the Cname column in the Sheet1 with the values from Name column in Sheet2 for the matching values in column CID(in Sheet1) and ID (in Sheet2). Attaching a sample excel sheet

    Help in writing a macro would be highly appreciated

    regards
    Nav
    Attached Files Attached Files

  2. #2
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640
    Why not use VLOOKUP?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  3. #3
    Registered User
    Join Date
    09-08-2008
    Location
    india
    Posts
    8
    could you elaborate how vlookup fits into my requirements

    many thanks..

  4. #4
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640
    You don't need VBA, use VLOOKUP formulas to match the ID number and place associated data into the column.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  5. #5
    Registered User
    Join Date
    09-08-2008
    Location
    india
    Posts
    8
    hi couldnt do it.. i tried different variations..

    If possible can up update the excel sheet i attached...

    thanks a tonne..!!!

  6. #6
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640
    In CName column use this formula in D2 and then copy it down

    =VLOOKUP(C2,Sheet2!$A$1:$B$10,2,FALSE)
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  7. #7
    Registered User
    Join Date
    09-08-2008
    Location
    india
    Posts
    8
    Thanks a tonnes it worked!!! You're a star!!!

    can it also work if the ID columnin sheet1 and ID column in sheet2 are not sorted. Is it necessary for them to be sorted?

    Also, there are multiple instances of same CIDS in sheet1 which makes it go awry


    Thanks in advance
    Last edited by naveenarora23; 09-08-2008 at 05:12 AM. Reason: incomplete description of problem

  8. #8
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640
    There's more help on VLOOKUP here

    http://www.excel-it.com/excel_functions.htm

    The formula will return the first instance of the ID and using the False statement will not require sorting.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  9. #9
    Registered User
    Join Date
    09-08-2008
    Location
    india
    Posts
    8
    Thanks a tonne. :-)

    u made my day!!! this is excellent forum i will recommend it to all...

+ 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.2.0