×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Linking New sheet to recorded information

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

RE: Linking New sheet to recorded information

The variable a does not represent a worksheet name, but is rather a full worksheet object.

The first thing I would try is the following:

Sheets(a.Name).Select    

RE: Linking New sheet to recorded information

(OP)
I tried that and it does not work. I think it has to do with the name being a variable? I just can't put my finger on it. Thanks for the reply, I really appreciate it.

RE: Linking New sheet to recorded information

A few thoughts:

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

(OP)
That did it. Thanks for helping out.

I just have one more question to post and I think I have this program completed! Everyone has been great on this site.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources