coping a sheet with macro

M

mcrmike

On my worksheet (totals hours worked each day for all employes) I have
macro assigned to a button (update) on the worksheet which copies th
sheet, deletes all data and then updates the dates to the next week
The problem is, when I click the button and it copies the worksheet i
always uses the original sheet (sheet1) instead of using the ne
updated sheet (sheet2,3,ect.) when I run the macro each additiona
time. Help would be greatly appreciated. Thanks
 
P

PegL

As I understand it, the button is on the 1st sheet of
your workbook. You click the button to create another
sheet with the new dates. Your macro probably either
references the name of the 1st sheet or ActiveSheet,
which will at that point be the 1st sheet. To accomplish
what you want, the macro needs to be changed to either
copy a hidden template or to determine which sheet it
should copy and use that sheet instead of the first
sheet. Another option would be to asociate the macro with
a custom toolbar and make sure the macro uses ActiveSheet
as the sheet to copy.
 
G

Gord Dibben

Your code most likely includes a hard-coded reference to "Sheet1".

Change that to ActiveSheet so it will work on whatever sheet you have in the
Window.

Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top