View Single Post
  #5   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

I tried that before I reposted.... and it puts
After: Sheet (3)
I will continue to play around with it...
Thanks again for your help.

"gocush" wrote in message
...
Turn on your macro recorder and do the same steps I followed above except

in
the Move or Copy Sheet dialog, select (move to end) in the Where section

of
the dialog.
After stopping the recorder open your VBE and look at the code. The

portion
of my above code line that reads:
Befo=Sheets(1)

will be different. That's what needs modifying.

"KimberlyC" wrote:

Thank you so much..... that works much better than mine.

One more Question....
How do I get the worksheets to add after the last sheet in the workbook.

I
won't know the name of the last sheet.

Thanks for you help!!!

"gocush" wrote in message
...
Kimberly,
I just opened a new wbk, named the three sheets, entered a formula
=Details!G8 in cell D7 of sheet Recap.
I then used the following code to create copies of the sheets

Sheets(Array("Recap", "Payroll", "Details")).Copy Befo=Sheets(1)

This created Recap (2), Payroll (2) and Details (2)
with the correct formula:
In Recap (2) Cell D7 the formula was automatically changed to
=Detail (2)!G7

Does your addin use the same code to create the copies? If not, try

this.
HTH

"KimberlyC" wrote:

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