S
Sloth
I recently created a new macro that copies a sheet named Template and changes
the name according to the result of cell K2, and then deletes cell K2 in the
new sheet. K2 contains the formula...
=TEXT(TODAY(),"mm-dd-yyyy")&" ;
"&TEXT(YEAR(TODAY()),"yy")&TEXT(TODAY()-DATE(YEAR(TODAY()),1,0),"###")
it outputs something like "12-19-2005 ; 05353"
and the code is
Sub Copy_Template()
Sheets("Template").Copy Before:=Sheets("Template")
Sheets("Template (2)").Name = Cells(2, 11)
Range("K2").Select
Selection.ClearContents
End Sub
I am extremely new to VBA coding and created this code by editing a recorded
macro. I have three questions concerning this macro.
1. How can I include the K2 formula in the coding?
2. I created a custom button and added it to the toolbar. If the file is
not open, I want the button to do nothing, or bringup an error message
(something like "This button is unavailible). Is this possible, or something
equally effective?
3. For you programers out there, is there anything majorly wrong with this
macro? In works for now, but I don't want to accidently overwrite, or
delete, anything in the future.
Also, can anyone suggest a good book to learn VBA programming?
the name according to the result of cell K2, and then deletes cell K2 in the
new sheet. K2 contains the formula...
=TEXT(TODAY(),"mm-dd-yyyy")&" ;
"&TEXT(YEAR(TODAY()),"yy")&TEXT(TODAY()-DATE(YEAR(TODAY()),1,0),"###")
it outputs something like "12-19-2005 ; 05353"
and the code is
Sub Copy_Template()
Sheets("Template").Copy Before:=Sheets("Template")
Sheets("Template (2)").Name = Cells(2, 11)
Range("K2").Select
Selection.ClearContents
End Sub
I am extremely new to VBA coding and created this code by editing a recorded
macro. I have three questions concerning this macro.
1. How can I include the K2 formula in the coding?
2. I created a custom button and added it to the toolbar. If the file is
not open, I want the button to do nothing, or bringup an error message
(something like "This button is unavailible). Is this possible, or something
equally effective?
3. For you programers out there, is there anything majorly wrong with this
macro? In works for now, but I don't want to accidently overwrite, or
delete, anything in the future.
Also, can anyone suggest a good book to learn VBA programming?