Getting sheetname that calls a macro.

E

Ed Davis

Is it possible to get the sheet name that a macro is called from.
I am using the code below to make a backup when the macro is called but it
can be called from any of 31 sheets.

Code =
ThisWorkbook.SaveCopyAs ThisWorkbook.Path &
"\Backup\Sales\Work\Change_Retails " & Format(Now, "dd-mm-yy hhmmss") &
".xls"
End of code

I would like to include the sheet name in the backup name
 
B

Billy Liddel

dim strSH as string

strSH = activesheet.name

Code =
ThisWorkbook.SaveCopyAs ThisWorkbook.Path &
"\Backup\Sales\Work\Change_Retails\"& strSH & Format(Now, "dd-mm-yy
hhmmss") & ".xls"

Not tested
 

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

Top