+ Reply to Thread
Results 1 to 5 of 5

Can I do a Loop to Name cells based on other cells?

  1. #1
    Registered User
    Join Date
    01-03-2014
    Location
    San Francisco
    MS-Off Ver
    Excel 2013/Office 365
    Posts
    13

    Can I do a Loop to Name cells based on other cells?

    I have multiple worksheets that correspond to each Quarter which then feed another sheet with the compiled data and not the details about where those numbers came from.
    I am looking to write a macro that Names all of the Totals Cells on the Quarter worksheets based on what account the totals are for, I have done it by hand a few times now but it is less than fun. I then reference the named cells on the Totals sheet instead of hand linking them.
    I tried just manually writing out each line of code to Name the cells but it just stopped working after the second line (but showed no errors). It is also allowing me to just use the text that is in the referenced cell but I want to add to it.

    As an example: I have an account named in B6 (PTH) and the totals are in B22 and B23, I would like to name B22 and B23 "PTHSKU4" and "PTHFACE4".
    I would like to do a loop that only runs this option every 5th row after the initial starting point and end when the final 5th row is empty.

    Any help is greatly appreciated!

    I have attached a document with an example which will hopefully make more sense.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Can I do a Loop to Name cells based on other cells?

    PTH is not in B6. It is in D6.

    I would like to do a loop that only runs this option every 5th row after the initial starting point and end when the final 5th row is empty.
    What 5th row are you talking about?

  3. #3
    Registered User
    Join Date
    01-03-2014
    Location
    San Francisco
    MS-Off Ver
    Excel 2013/Office 365
    Posts
    13

    Re: Can I do a Loop to Name cells based on other cells?

    Thanks stnkynts,
    Sorry I was looking at the wrong sheet of the file that I copied from and it has more columns between the accounts and less columns in the beginning.

    So to correct my example question to match the attached workbook:

    I want D6 to help populate what I want D22 to be named and then G6 to help populate G22 (so every third column) until it reaches an empty cell and then I want it to stop.
    One of the issues I am having is I want D22 to be named PTHSKU4 and D23 to be name PTHFACE4. I can only figure out how to name it "PTH" by directly referencing D6.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Can I do a Loop to Name cells based on other cells?

    Instead of a different name for each store, you could use a name that will read the store number from column A and return its SKU from the other sheet.

    select a cell in the NC Totals Total sheet row 6 and define a name
    Name: StoreSku
    RefersTo: =INDEX('Q4 FY14 Details NC'!$22:$22,1,MATCH($A6,'Q4 FY14 Details NC'!$6:$6,0))

    Then =StoreSku in G6 and drag down.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    01-03-2014
    Location
    San Francisco
    MS-Off Ver
    Excel 2013/Office 365
    Posts
    13

    Re: Can I do a Loop to Name cells based on other cells?

    mikerickson
    Thanks!
    Worked great. You saved me a ton of time, much appreciated.

+ 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] For loop sum cells based on criteria.
    By Petter120 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-04-2014, 09:04 AM
  2. [SOLVED] Run / loop through cells and delete based on criteria
    By Coeus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2014, 04:37 PM
  3. Insert New row in another sheet and Loop based on values in certain cells
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-14-2013, 02:25 PM
  4. Loop based on frequncy in cells
    By arbeg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-06-2010, 06:27 AM
  5. A loop to merge cells based on a value
    By tschultz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-24-2005, 02:50 PM

Tags for this Thread

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