+ Reply to Thread
Results 1 to 8 of 8

Code/Rules for pulling cells between tabs

  1. #1
    Registered User
    Join Date
    04-21-2017
    Location
    PA, US
    MS-Off Ver
    14.0.7128.5000
    Posts
    4

    Code/Rules for pulling cells between tabs

    Hello All,

    I wanted to thank you ahead of time for any time spent on helping me.
    I am looking to create logic so no matter who uses the document certain rules will stay in place. Referencing the attached file there there are two tabs; Overview and Budget. I am looking to use a formula in the Overview tab in Columns A, B, C and D below row 14 which will look for new categories and totals that are added to the Budget tab.
    For example: if a user was to add category 7 to the budget tab there would be a formula in row 20 column A in the Overview tab which would bring the category name over and then formulas in row 20 columns B, C, and D which would take the totals from Category 7 as well.
    I tried using code to recognize bold characters and bring over the bold Categories but was unable to figure out how to get Row 15 to recognize that Category 1 had already been used in row 14 and to move on to the next for row 15.

    Please Login or Register  to view this content.
    Since I wasn't able to make it past pulling over the category tab I didn't even attempt to try and get columns B, C and D to only pull totals from the Category listed in column A.
    Any help would be greatly appreciated.
    Attached Files Attached Files
    Last edited by Leith Ross; 04-21-2017 at 11:27 AM. Reason: Added Code Tags

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Code/Rules for pulling cells between tabs

    Welcome to the forum!

    I think you're making life hard on yourself by trying to use bold as an identifier of categories. If you use a helper column, I believe you can do this with formulas alone. In my attachment, I've turned column Q on "Budget" into a helper column. I use the following formula, which must be array-entered (using Ctrl + Shift + Enter instead of Enter) in Q7, then filled down:

    =IF(AND($A7<>"",ISBLANK($B7:$N7)),"Category",IF($A7="Total",$A7,IF(AND(ISBLANK($K7:$N7)=FALSE,ISBLANK($B7:$J7)),"Subtotal","")))

    This formula should label your category, total, and subtotal rows so that they can be easily identified in the next part of my solution. I've left the helper column visible in the attachment, but you can easily hide it to keep it out of view.

    Using the helper column, you can use the following formula, which must also be array-entered, in the Overview sheet, cell A14:

    =IFERROR(INDEX(Budget!$A$7:$A$100,SMALL(IF(Budget!$Q$7:$Q$100="Category",ROW(Budget!$Q$7:$Q$100)),ROW(1:1))-6),"")

    Fill it down beyond what you need and it should auto-populate with all of your categories. It will also automatically include any changes or new categories that are added to the budget sheet. You can then use the formula below (array-entered again) in B14:

    =IFERROR(INDEX(Budget!K$7:K$100,SMALL(IF(Budget!$Q$7:$Q$100="Subtotal",ROW(Budget!$Q$7:$Q$100)),ROW(1:1))-6),"")

    Fill it right through D14 and down and it will return the subtotals for each category.

    You can modify the formula to provide your "spending to date" numbers as well in column F. With everything in place, you should not have to touch the Overview sheet anymore. It should automatically reflect any changes to the budget sheet.

    My formulas are currently set up to cover through row 100 of the Budget sheet, but you can increase that number if you expect more rows to be used. Just make sure you increase all of them so the sizes of the arrays still match. Take a look at the attachment and see if it'll do the trick:
    Attached Files Attached Files
    If your problem has been solved, please use "Thread Tools" to mark the thread as "Solved".

    If you're grateful for this site's existence and would like to contribute to the community, please consider posting something hilarious in our joke thread:
    https://www.excelforum.com/the-water...ke-thread.html

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Code/Rules for pulling cells between tabs

    Hello cuttothechase,

    Welcome to the forum!

    Here is the VBA code to copy the categories automatically. The macro is called whenever the "Overview" worksheet becomes the active sheet. All the categories are updated when this occurs.

    The attached workbook has the macros added.

    Overview Event Code
    Please Login or Register  to view this content.
    Copy Categories Macro Code
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    04-21-2017
    Location
    PA, US
    MS-Off Ver
    14.0.7128.5000
    Posts
    4

    Re: Code/Rules for pulling cells between tabs

    @cAntosh

    Thank you so much for the help. This worked wonderfully. I appreciate your time.

  5. #5
    Registered User
    Join Date
    04-21-2017
    Location
    PA, US
    MS-Off Ver
    14.0.7128.5000
    Posts
    4

    Re: Code/Rules for pulling cells between tabs

    @Leith Ross

    Thank you for your reply. When I tried putting my input along with the code in your file I was unable to get it to recognize new Categories but I was able to get it to work with the previous posters solution.
    Thank you for your time in helping find a resolution!

  6. #6
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Code/Rules for pulling cells between tabs

    Glad to help, good luck!

  7. #7
    Registered User
    Join Date
    04-21-2017
    Location
    PA, US
    MS-Off Ver
    14.0.7128.5000
    Posts
    4

    Re: Code/Rules for pulling cells between tabs

    Hi cAntosh. Your fix is working great but I do have one additional question.
    Using the file you uploaded, now that you have enabled me to add additional categories in the Budget tab by using the Helper Column (Q), how can I get the total in row 53 to update for any additional Categories.

    For example: If I copy rows 45 through 51, make a copy and then insert the copied cells to make an additional Category, the SUM formula that I have in Row 60 columns K, L, M and N no longer contain the subtotal from row 51.
    How can I get the Total row to recognize when a new Subtotal row has been added and to count the new subtotal as well?

    Thanks again.

  8. #8
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Code/Rules for pulling cells between tabs

    The helper column is there, so you might as well use it for your sums, too. I would change your SUM formula in K53 to the following:

    =SUMIF($Q$7:$Q52,"Subtotal",K$7:K52)

    This formula should sum the numbers above that fall into rows identified as "Subtotal" rows. It should respond better to the insertion of new rows. You can fill right for the other totals.
    Attached Files Attached Files

+ 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. Pulling cells through to different tabs and retaining their web links
    By mparker123 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-02-2014, 04:58 AM
  2. Excel VBA code to sort table and move cells around according to set rules
    By abdul4me in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-22-2013, 07:18 AM
  3. Pulling info from Tabs across spreadsheet
    By C.j. in forum Excel General
    Replies: 8
    Last Post: 12-14-2012, 04:25 PM
  4. Replies: 5
    Last Post: 07-06-2012, 08:25 AM
  5. Pulling qtys from different tabs
    By jackdpricejr in forum Excel General
    Replies: 4
    Last Post: 03-01-2012, 06:59 AM
  6. Pulling certain lines from other tabs
    By aeewing in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-01-2011, 09:54 AM
  7. Pulling data from multiple tabs
    By RevJeff in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-22-2008, 11:08 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