+ Reply to Thread
Results 1 to 7 of 7

[Solved] Assistance with Vlookup to match old accounts to new accounts

Hybrid View

  1. #1
    Registered User
    Join Date
    04-09-2015
    Location
    New York, United States
    MS-Off Ver
    2007, 2013
    Posts
    6

    [Solved] Assistance with Vlookup to match old accounts to new accounts

    Hi all,

    I am doing an internship and have been given a task involving macros to which I could use some help. I apologize if I confuse you with my description.

    We are currently switching accounting systems and I am interested in a macro that takes the old account number and in a separate column gives me the new account number.

    There is a workbook that lists the old account numbers and their corresponding new account numbers. In a separate workbook I have 88 worksheets for various different projects that need the accounts to be matched with the new account numbers.

    Essentially, I need a macro that say if I have "xxxx" in A# then I# = "xxxx". If A# is empty then I# is empty.

    Here is an example:
    Book1.xlsx

    Thanks in advance for your help,
    Mike
    Last edited by Mosdaboss; 04-22-2015 at 12:58 PM.

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macro Help

    So just to get this right in my head, are you looking for a macro that will cycle through all of the worksheets(88) and for any row with a value in column A, lookup the new value and put it in column I?
    If someone has helped you then please add to their Reputation

  3. #3
    Registered User
    Join Date
    04-09-2015
    Location
    New York, United States
    MS-Off Ver
    2007, 2013
    Posts
    6

    Re: Macro Help

    Quote Originally Posted by pjwhitfield View Post
    So just to get this right in my head, are you looking for a macro that will cycle through all of the worksheets(88) and for any row with a value in column A, lookup the new value and put it in column I?
    Yes. I assume it would be some fancy IF function that I can't grasp my head around, such as

    =IF(A1=6200, "5200", "")

    I know that is a very basic IF function. I'm thinking if I can replace A1 with something so that it doesn't matter what cell in column A, the number is in, then I could just make around 220 separate IF functions and save them in one macro. Am I thinking in the right direction?

    Quote Originally Posted by pjwhitfield View Post
    I assume where in the Old Accounts you have 2 numbers separated by a slash that any account with either of those numbers will take on the single new number? eg 6405 and 6400 both become 5420
    Yes, although I could edit the list and put them in a separate row. They're only in the same cell because the description is the same. Whereas 6500, 6501, and 6510 equal 5500, but are on separate rows because their descriptions are different.

    Thanks again.

  4. #4
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macro Help

    I assume where in the Old Accounts you have 2 numbers seperated by a slash that any account with either of those numbers will take on the single new number? eg 6405 and 6400 both become 5420

  5. #5
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macro Help

    if you can reorganise the reference table to remove the / entries ie split those into 2 rows then VLOOKUP will be your friend. if not then it'll need a bit of VBA

    Basically, create a table of Old and New Accounts in Old Number order, give the range a name (ive used "accNumbers"), you do this by highlighting all of the range (minus the headers) and typing a name in the box that normally shows the cell reference. Then refer to it in a VLOOKUP in column I
    =IFNA(VLOOKUP(A2,accNumbers,2,FALSE),"")
    Ive wrapped the VLOOKUP in an IFNA to give blanks where no resulting value is found.

    Ive done the first sheet for you in your example, simply copy and paste the formula above into I2 of the each sheet and drag it down to the bottom.
    Attached Files Attached Files

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Macro Help

    Mike, welcome to the forum

    Please take a moment to read the forum rules and then amend your thread title to something descriptive of your problem - not what you think the answer might be. (think google search terms?). Once you have done this please send me a PM and I will remove this request. (Also, include a link to your thread - copy from the address bar)

    Many members search our previous posts, and thread titles play a big part of the search. I doubt anybody would do a search based on your title?

    To change a Title on your post, click EDIT POST then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Registered User
    Join Date
    04-09-2015
    Location
    New York, United States
    MS-Off Ver
    2007, 2013
    Posts
    6

    Re: Assistance with Vlookup to match old accounts to new accounts

    Thanks for your help, wouldn't have been able to do it without your help.

    Since I have Excel 2013 at home and Excel 2007 at work, I just had to make a slight modification to the code. For those interested:

    Here is the code that works in Excel 2013 courtesy of user, pjwhitfield.
    =IFNA(VLOOKUP(A2,accNumbers,2,FALSE),"")
    Here is the code that works in Excel 2007.
    =IFERROR(VLOOKUP(A2,accNumbers,2,FALSE),"")
    Essentially Excel 2007 uses IFERROR, while Excel 2013 uses IFNA.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using a macro on workbook1 to create a button in wb2 and assigning macro "wb2!macro"
    By penfold1992 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2014, 11:39 AM
  2. [SOLVED] Macro to show Which macro didnt work in a nested macro
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-10-2013, 03:21 AM
  3. Perform macro "on open" specific file- store macro in Personal Macro Workbook?
    By thompssc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2012, 12:38 PM
  4. lookup macro, solver macro, realtime macro
    By xelhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2011, 06:14 PM
  5. Cannot find macro error when running a macro from a macro in a diffrent workbook.
    By Acrobatic82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2010, 09:22 AM

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