Macro to rename Tab and then save as

C

Construk

Hi,
I'm trying to do a macro thatdoes 2 things:

1- Rename the active Tab with the content of a cell in it

dimvar = Date1
Range("AB2").Select
(?)Selection.Copy = Date1
ActiveWorkbook.Worksheets.Select
(???).Name = Date
Range("A4").Select
End Sub

2- Then, use this same Tab name and add it after an other word

Case-Date1.xlsm

Michel
 
D

Dave Peterson

Dim wks as worksheet
set wks = activesheet
with wks
.name = .range("Ab2").value
'or if AB2 contains a date, you can make sure that the
'value is legal (sheet names can't contain /'s).
.name = Format(.range("AB2").value, "yyyy-mm-dd")
end with

and maybe...

dim myStr as string
Dim wks as worksheet
set wks = activesheet
with wks
.name = .range("Ab2").value
'or if AB2 contains a date, you can make sure that the
'value is legal (sheet names can't contain /'s).
.name = Format(.range("AB2").value, "yyyy-mm-dd")
mystr = "Case-" & .name & ".xlsm"
end with
 
C

Construk

Thanks Dave!

Dave Peterson said:
Dim wks as worksheet
set wks = activesheet
with wks
.name = .range("Ab2").value
'or if AB2 contains a date, you can make sure that the
'value is legal (sheet names can't contain /'s).
.name = Format(.range("AB2").value, "yyyy-mm-dd")
end with

and maybe...

dim myStr as string
Dim wks as worksheet
set wks = activesheet
with wks
.name = .range("Ab2").value
'or if AB2 contains a date, you can make sure that the
'value is legal (sheet names can't contain /'s).
.name = Format(.range("AB2").value, "yyyy-mm-dd")
mystr = "Case-" & .name & ".xlsm"
end with
 

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