View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
KimberlyC KimberlyC is offline
external usenet poster
 
Posts: 124
Default Setting a formula with code in worksheet added

Hi!

I have a workbook that has three worksheets in it.
Recap (sheet 1), Payroll (sheet 2), and Details (sheet 3).

I also have an addin file that loads with this workbook and it contains all
the codes to operate the buttons and menus on the workbook.

In the addin file I have the same three worksheets (recap, payroll, and
details). These were put in the addin file...inorder to run code that
copies these worksheets and adds them to the activeworkbook incase the users
needs more of those sheets. If one sheet is added they all three added
.....as they work together.

So... after a one set of the worksheets have been added.. the workbook
contains the following sheets:
Recap, Payroll, Detail, Recap (2), Payroll (2), Details (2)

They can added as many sets as needed....my guess is it won't go over 20
sets..but you not 100% sure.

Anyway... Adding the sheets is working fine...... however.. I now have
formulas that are in the Recap sheet that link to the Details sheet and I
need to add the formula to the added recap sheets...when it is added and
have it correspond to the added Details sheet that works with it...

Is there a way to add a formula to the added Recap sheet that will reference
the added Details sheet .....keep in mind I won't know the number of the
sheets added...as the user can add as many sets as needed. They are added
is sets ... which I think helps with running the code to do this..

The formula needs to go into cell D8 of the Recap sheets added and is
=Details(with corresponding page #)!G7

Maybe.... there is a way to look at the Recap sheet number that has been
added ( for ex...Recap (2) ) and have code set cell D8 of the Recap (2) to
=Details (2)!G7 and so on... so when a thrid set of sheets are added... the
sheets would be Recap (3), Payroll (3), and Details (3)...and the formula
needed in Recap (3) cell D8 would need to be =Details (3)!G7

I hope this made sense....it was hard to explain.. :)

Any help would be greatly appreciated..
Thanks in advance..
Kimberly