Linking New sheet to recorded information
Linking New sheet to recorded information
(OP)
I created a new worksheet with the current date in a macro. With the recorder I cut and pasted data into the new sheets. But the next day when the date changes, the macro doesn't work because it identifies with the worksheet name on the date recorded
The code for the date is:
Dim a As Worksheet
On Error Resume Next
Set a = Sheets([text(today(),"mm-dd-yyyy")])
If Err.Number = 0 Then Exit Sub
Application.ScreenUpdating = False
Set a = ActiveWorkbook.Worksheets.Add(after:=Sheets(Sheets.Count))
a.Name = [text(today(),"mm-dd-yyyy")] & " Quotes"
Application.ScreenUpdating = True
Set a = Nothing
And when it is running the macro is uses:
Range("A1:L11").Select
Selection.Copy
Sheets("10-29-2003 Quotes").Select
ActiveSheet.Paste
I tried changing: Sheets("10-29-2003 Quotes").Select
To: Sheets(a).Select But that did not want to take it.
Is this something right in front of me that I can't see???
Thanks in advance
The code for the date is:
Dim a As Worksheet
On Error Resume Next
Set a = Sheets([text(today(),"mm-dd-yyyy")])
If Err.Number = 0 Then Exit Sub
Application.ScreenUpdating = False
Set a = ActiveWorkbook.Worksheets.Add(after:=Sheets(Sheets.Count))
a.Name = [text(today(),"mm-dd-yyyy")] & " Quotes"
Application.ScreenUpdating = True
Set a = Nothing
And when it is running the macro is uses:
Range("A1:L11").Select
Selection.Copy
Sheets("10-29-2003 Quotes").Select
ActiveSheet.Paste
I tried changing: Sheets("10-29-2003 Quotes").Select
To: Sheets(a).Select But that did not want to take it.
Is this something right in front of me that I can't see???
Thanks in advance





RE: Linking New sheet to recorded information
The first thing I would try is the following:
Sheets(a.Name).Select
RE: Linking New sheet to recorded information
RE: Linking New sheet to recorded information
Is your code in two different Subs? Excel will not know in the second Sub what a was earlier.
Next, you set a = nothing in the first part of code. This will release the object a, so you can no longer reference it.
3rd, if you properly have set a to a sheet (by Set a =ActiveWorkbook.Worksheets.Add, you can select the sheet simply by a.Select
So you can try setting a again to the proper sheet once that has been added if required:
Set a = Sheets([text(today(),"mm-dd-yyyy")])
ActiveSheet.Range("A1:L11").Copy
a.Paste
I hope I understood you correctly...
Cheers,
Joerd
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
RE: Linking New sheet to recorded information
I just have one more question to post and I think I have this program completed! Everyone has been great on this site.