+ Reply to Thread
Results 1 to 7 of 7

Populating various cells in a range based on a table of cell addresses

  1. #1
    Registered User
    Join Date
    01-19-2013
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    4

    Populating various cells in a range based on a table of cell addresses

    Hi,

    I'm very new to using VBA, but hoping that there is a simple solution to my situation:
    1. I have a table of cell addresses, under a set of "codes" (F, NC, PL, etc.) i.e. (sorry, having hard time getting the table layout to display properly):

    | AJ | AJ | AK | AM | AN | AO | AP | AQ

    9 | F | NC | PL | FL | P1 | P2 | P3 | P4
    10 | $F$10 | $J$10
    11 | | | $H$11 | $L$11
    12 | | | | | $H$11 | $Q$11 | $Y$11

    2. I would like to populate the target cells (elsewhere in the same sheet) rerefenced by the addresses in each of the cells in the table, with the code at the top of each column in the table. For example, the cell f10 would be populated with the value "F", cell J10 with the value "NC"...right through to Y11 being populated with the "P3" value.

    I'll reiterate that I'm very new to VBA, so likely need some step-by-step direction, plus the code! Any help would be much appreciated. Thanks.

  2. #2
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Populating various cells in a range based on a table of cell addresses

    How about this?
    The table solution is a bit more flexible.

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Jacc; 01-19-2013 at 06:41 AM.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  3. #3
    Registered User
    Join Date
    01-19-2013
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Populating various cells in a range based on a table of cell addresses

    Thanks for the response Jacc. I must be doing something wrong though. When I run the macros in the book you sent, I get only a "P3" in cell Y11 with the named range solution, and the table solution give a run time error 1004 (Method 'Range' of object '_Global' failed. I use Excel 2003 - maybe that is causing the problem.

    Any suggestions?

    Thanks

    Craig

  4. #4
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Populating various cells in a range based on a table of cell addresses

    Sorry, I missed that you are on Excel 2003, the table solution will not work there.

    As for the Named Range solution it works perfectly well here and I don't see any reason it shouldn't work on 2003.
    The other addresses are outside the view to the left, did you scroll far enough to the left to see them?

    Hmm... at closer inspection the addresses are surrounded by spaces. The reason for this is that I copied them from your first post and then used Text to Columns to separate them. But then again, Y11 was also surrounded by spaces.

    Here is a new version to try, all spaces removed and all results within visible range.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-19-2013
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Populating various cells in a range based on a table of cell addresses

    Hi Jacc,

    Just getting back to this - thanks. This looks like it works. However, I have been thinking about this some more and fear that my setup here may have been over-complicated. I've attached what I think is a simplified setup (attached sheet, rows 3-11), which shows the desired outcome (rows 14-22). In summary:

    1. I've got an input table (shown on attachment in columns B-E) where users enter event (i.e. launch step 1, launch step 2, etc.) dates (the dates they enter are sequential calendar quarters starting in January, 2013 (that would be Q1) for a list of products

    2. On another sheet (shown in the attachment on the same sheet in columns G-P for simplicity), there is ths same list of products, with a number of rows associated with each. I'd like one of the rows associated with each product to be populated with the event names, in the cells that correspond to the dates for those events, as entered in the table. For example, "Launch step 2" for product #2 was entered as taking place in calendar quarter 6 (Q2 of the second year), so I'd like the cell in the "Product 2 Launch" line, in the Q6 column to be populated with the event label "Step 2" as indicated in the table.

    My original approach involved converting the date entries to cell references, but it seems that maybe I can simplify by just referencing the cells based on their column number (quarter number), as per my example.

    Does this make sense? Any suggestions? Note that I'm working in Excel 2003. Thanks in advance.
    Attached Files Attached Files
    Last edited by cm115; 01-23-2013 at 05:40 PM.

  6. #6
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Populating various cells in a range based on a table of cell addresses

    Here are some solutions, I made an arrayformula one as well just for kicks. I can't say I'm really happy with either one but I think the array formula one may actually be easier to work with.

    The reason I'm not happy with either solution is that I feel that both algorithms are pretty clumsy. If anyone wants to improve them you are more than welcome!
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Populating various cells in a range based on a table of cell addresses

    This one is no less clumsy but at least it's more generic. It's easier to add columns.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula: copy to clipboard
    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)

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