PDA

View Full Version : [SOLVED:] Automatically sum cell values from new sheets (that are not created yet)



eivindv
02-20-2014, 01:26 AM
Hi everyone,

I posted a thread yesterday called "Automatically give new sheet name (created frm template w/macro) the value of a cell", and now I have a new question that is in a way connected with this.

I have a book that will contain sheets (created from a template as described in the thread above) where the sheets names will be names of people. In this same book I have a "summarize-sheet", where I have a table that summarizes certain values from the templates that are made. I know how to summarize if the sheets are already made, but what can I do to create sum-formulas in the table which takes into consideration that the values are in sheets that not neccesarily are made yet? I understand this is a vba-forum, and that this may be solved with just a formula (?), but can some of you help me with a formula that does this? The thing is, that the sheet names are known because the values in S10 that creates the sheet names (from my previous thread) comes from a pre-defined list of people. So I think the formula in the summarize-table can be written with some "if a sheet name that has the name X exists, then get cell value Y from that sheet name. If not, return blank"-sentence...

Do you understand what I am trying to do? If it is wrong to post it here, Im sorry. I have tried to search in different forums, but can't find a solution, and the help I got with my thread yesterday was excellent, so.. :)



-Eivind

Bob Phillips
02-20-2014, 10:28 AM
What I would do is add a sheet called First, before any of the existing sheets, and another called Last, after all existing sheets, and use formulae such as

=SUM(First:Last!A1:A5)

Make sure there is nothing in A1:A5 in First and Last, then hide First and Last so that hey don't get in the way. If you manually add a sheet it will go somewhere between them. If you add sheets by VBA, make sure you add it after Worksheets.Count - 1.

sassora
02-22-2014, 10:53 AM
Wow that is amazing, never seen that use of worksheets in a formula before :)

eivindv
02-24-2014, 12:21 AM
Hi again,

Thank you, it works just like I want it to :)

Excellent help in here, great forum for newbies to learn!


Best, Eivind