+ Reply to Thread
Results 1 to 4 of 4

Macro to insert text into a cell based on another cell's number

  1. #1
    Registered User
    Join Date
    09-14-2015
    Location
    United States
    MS-Off Ver
    2010
    Posts
    8

    Macro to insert text into a cell based on another cell's number

    How would I go about writing a macro can for a number like 950 put in the cell next to it HR and for 970 put in Accounting and so on so forth. I need it to fill in Dept name based on what is in column A.

    How the spread sheet is set up


    Column A Column B
    Dept # Dept Name
    950 HR
    980
    960
    970 Accounting
    999

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

    Re: Macro to insert text into a cell based on another cell's number

    So do you have a list of codes and departments in your spreadsheet like the example above? Assuming that list is in column D and E say then you can just use VLOOOKUP

    in B2 enter
    Please Login or Register  to view this content.
    and drag down
    If someone has helped you then please add to their Reputation

  3. #3
    Registered User
    Join Date
    09-14-2015
    Location
    United States
    MS-Off Ver
    2010
    Posts
    8

    Re: Macro to insert text into a cell based on another cell's number

    I do have a list of codes, the reason i want a macro is because I am putting together one big macro to do a bunch of stuff on this one spread sheet. So this is part of it after it runs this it will do something else.

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

    Re: Macro to insert text into a cell based on another cell's number

    to use it in VBA refer to it using WorksheetFunction.Vlookup

+ 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. Replies: 6
    Last Post: 04-15-2015, 10:25 PM
  2. lock and insert formula in a cell based on selection of text in another cell
    By alirazafazal in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2014, 06:08 AM
  3. If cell equals a text then insert a number, (text cell comes from a data validation)
    By floridashaughn in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-15-2014, 03:24 PM
  4. [SOLVED] Excel Macro, VBA help needed - Insert Cell based on value of a cell in another column
    By alw99 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2014, 05:22 PM
  5. [SOLVED] Event Macro to insert text in cell based on input of another cell
    By nplouffe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-08-2012, 11:54 AM
  6. [SOLVED] Insert text to cell based on whether the value begins with a letter or number.
    By BPSJACK in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-23-2012, 09:57 AM
  7. Need Help w/Macro That Will Insert Column Based on Specific Text in a Given Cell
    By pb6933944 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-23-2012, 12:23 PM

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