Command code

V

Very Basic User

Hello,

I'll try to explain what I want a command to perform, any help would be
greatly appreciated.

I have a file "RCA TRIGGERS.XLSM" I want to add a command button that when I
hit it, it does the following. Copy the current sheet to the end of the
workbook, name the new tab by date and time, clear out the old form, and then
re-save the file. I tried to record a macro to do this and almost had it. The
only problem was that I can't name the tab with the characters that are used
in a date and time.

The second command I want is to hit a button that opens E-mail, attaches the
current sheet as an attachment, and sends the sheet to a specific
distribution list.

Any help will be valued.
 
D

Dave Peterson

Option Explicit
Sub testme()

ActiveSheet.Copy _
after:=Sheets(Sheets.Count)

'the new sheet is now the activesheet
ActiveSheet.Name = Format(Now, "yyyy-mm-dd_hh-mm-ss")

End Sub

There are characters and names you can't use when you name a sheet. I liked
this format of the date/time. But you may want to change to something you like.
 
V

Very Basic User

You guys in here are incredible, I've been trying to figure this out for
hours. Thank you!
--
Thank you for your time!
John


Dave Peterson said:
Option Explicit
Sub testme()

ActiveSheet.Copy _
after:=Sheets(Sheets.Count)

'the new sheet is now the activesheet
ActiveSheet.Name = Format(Now, "yyyy-mm-dd_hh-mm-ss")

End Sub

There are characters and names you can't use when you name a sheet. I liked
this format of the date/time. But you may want to change to something you like.
 

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

Similar Threads

Code for Command Buttons 1
Command Button and macro 4
Text in a command 2
Excel Monthly Spread sheet. 12
Date Search 2
Help to create a macro 2
stationary command button 2
VBA in shared workbook 5

Top