+ Reply to Thread
Results 1 to 7 of 7

loop thru cells in column and depending on cell value, populate another cell with a value

  1. #1
    Registered User
    Join Date
    01-23-2014
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    4

    loop thru cells in column and depending on cell value, populate another cell with a value

    can someone help me with my macro? i need to loop thru cells in column A and depending on each cell's value, populate another column's cell with a value i need to hardcode in the macro using a case statement.

    attached is a workbook containing a macro MODULE3.OPAY showing my attempt (which is poor, i know). the way it is now, the macro populates the whole column A with 16750, but i need to have it place column header 'COID' in Q2, then place the new values in column Q.

    thanks so much in advance for your assistance!!

    Pam White
    [email protected]
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: loop thru cells in column and depending on cell value, populate another cell with a va

    Not sure if this helps or not. I may have misunderstood.

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,176

    Re: loop thru cells in column and depending on cell value, populate another cell with a va

    I still think VLOOKUP() would do this..but heres a better scanning code...but I dont know where your getting the SUM, TRO, etc. values.

    Please Login or Register  to view this content.
    Last edited by ranman256; 05-16-2014 at 01:06 PM. Reason: better idea

  4. #4
    Registered User
    Join Date
    01-23-2014
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: loop thru cells in column and depending on cell value, populate another cell with a va

    thanks!! this works perfectly for the first 4 cases, but the last 3 need to be mid(11,3) so the case left c,3 doesn't pick up the right characters. thoughts?

  5. #5
    Registered User
    Join Date
    01-23-2014
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: loop thru cells in column and depending on cell value, populate another cell with a va

    ranman256,
    the "SUM" "TRO" "RIV" etc are strings of text in the col A cells (partial values). for the first 4 cases, i need to look at the first 3 characters but for the last 3, i need to look at the 11th, 12th and 13th characters. were you able to look at my attached file? thanks so much!!

  6. #6
    Registered User
    Join Date
    01-23-2014
    Location
    Tennessee
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: loop thru cells in column and depending on cell value, populate another cell with a va

    ranman256,
    I changed the code to be the exact value of text in col A cells and it works perfectly. how can i set q2 to "COID" (a header)?

    Quote Originally Posted by pwhite View Post
    ranman256,
    the "SUM" "TRO" "RIV" etc are strings of text in the col A cells (partial values). for the first 4 cases, i need to look at the first 3 characters but for the last 3, i need to look at the 11th, 12th and 13th characters. were you able to look at my attached file? thanks so much!!

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: loop thru cells in column and depending on cell value, populate another cell with a va

    Try:

    Please Login or Register  to view this content.

+ 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. [SOLVED] Inserting IF Function and depending on answer have cell populate with another cell.
    By Rhiannon25 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 04-03-2013, 02:17 AM
  2. [SOLVED] IF forumla - need to populate a cell on one sheet depending on range of cells in another
    By Emma2902 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-14-2012, 07:43 AM
  3. Cell to Cell reference and populate depending on source value
    By rsmith777 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2012, 10:16 AM
  4. Replies: 16
    Last Post: 03-09-2011, 12:27 PM
  5. Populate Cells depending on criteria of other cell
    By thedaddy in forum Excel General
    Replies: 1
    Last Post: 09-05-2009, 12:42 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