Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Don Don is offline
external usenet poster
 
Posts: 487
Default Add a Sheet From a Previous Sheet Macro

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").S elect
Selection.ClearContents
Range("G12").Select
End Sub:

Regards and thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Add a Sheet From a Previous Sheet Macro

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



Don wrote:

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").S elect
Selection.ClearContents
Range("G12").Select
End Sub:

Regards and thanks in advance.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Don Don is offline
external usenet poster
 
Posts: 487
Default Add a Sheet From a Previous Sheet Macro

Thanks Dave. It worked like a charm. Why is the answer so obvious after
somebody give it to me!!

"Dave Peterson" wrote:

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



Don wrote:

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").S elect
Selection.ClearContents
Range("G12").Select
End Sub:

Regards and thanks in advance.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Add a Sheet From a Previous Sheet Macro

I guess it's the same reason it's easy to pick last week's lottery numbers!

Don wrote:

Thanks Dave. It worked like a charm. Why is the answer so obvious after
somebody give it to me!!

"Dave Peterson" wrote:

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



Don wrote:

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").S elect
Selection.ClearContents
Range("G12").Select
End Sub:

Regards and thanks in advance.


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlinks - macro not working to take them off the sheet Lorelei New Users to Excel 1 September 23rd 06 02:18 AM
Rehide Sheet in macro. ChuckF Excel Worksheet Functions 3 March 29th 06 10:39 PM
Finding and compiling list of cells containing data... Richard Walker Excel Worksheet Functions 6 March 18th 06 02:17 PM
Does excel recognise names rather than cells? Sue Excel Worksheet Functions 9 May 22nd 05 04:51 AM
Can a macro format a hidden sheet? Robert Excel Discussion (Misc queries) 1 February 9th 05 06:13 PM


All times are GMT +1. The time now is 11:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"