Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / November 2006

Tip: Looking for answers? Try searching our database.

Add a Sheet From a Previous Sheet Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don - 10 Nov 2006 19:50 GMT
I have a daily reporting system in which I have a macro to make a new sheet
as well as clear some information from the previous sheet in a workbook with
muliple sheets of different names besides DR(1) etc. Since the number of days
per job is variable, I need to add something into the macro to copy the
previous day information to the new sheet instead of reverting back to the
original to make a copy of it. The macro that I use now is below and you can
see it copys DR(1) when I would like it to copy from DR(6) if that sheet
happens to be in the workbook. I'm not sure what to add in and everthing
tried to date has not worked.

Sub NewDay()

Sheets("DR(1)").Copy After:=Sheets("DR(1)")
Range("U1") = Range("U1") + 1
Range("G12:O31,Q44:V49,H47:H49,K46:K49,N46:N49").Select
Selection.ClearContents
Range("G12").Select
End Sub:

Regards and thanks in advance.
Dave Peterson - 10 Nov 2006 20:04 GMT
How about just working against the activesheet?

So select the sheet to copy first, then run the macro.

Sheets("DR(1)").Copy After:=Sheets("DR(1)")
becomes
Activesheet.Copy After:=activesheet

> I have a daily reporting system in which I have a macro to make a new sheet
> as well as clear some information from the previous sheet in a workbook with
[quoted text clipped - 16 lines]
>
> Regards and thanks in advance.

Signature

Dave Peterson

Don - 10 Nov 2006 20:55 GMT
Thanks Dave. It worked like a charm. Why is the answer so obvious after
somebody give it to me!!

> How about just working against the activesheet?
>
[quoted text clipped - 24 lines]
> >
> > Regards and thanks in advance.
Dave Peterson - 10 Nov 2006 23:41 GMT
I guess it's the same reason it's easy to pick last week's lottery numbers!

> Thanks Dave. It worked like a charm. Why is the answer so obvious after
> somebody give it to me!!
[quoted text clipped - 31 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.