VB code to save worksheet as...

G

Guest

Hi,

At the end of my vb code I would like the worksheet to be saved giving it
the name of 2 cell refs
1st cell ref J3 which holds a date ie 15 March 2007
2nd cell ref U3 which holds a game number

so example J3 = 15 MARCH 2007 , U3 = GAME 4

save worksheet name as 15MARCH2007GAME4

any ideas ?
thanks
 
I

Incidental

Hi

you could try adding the cells refs to a string then use that as your
saveas name.

Option Explicit
Dim fName As String

Private Sub CommandButton1_Click()
fName = [j3] & [u3]
ActiveWorkbook.SaveAs Filename:=fName
End Sub

hope this is of some help

S
 
I

Incidental

Sorry i just read your message again and think you were wanting to
rename the sheet which in that case you could use

Option Explicit
Dim fName As String
Private Sub CommandButton1_Click()
fName = [j3] & [u3]
ActiveSheet.Name = fName
ActiveWorkbook.Save
End Sub

S
 
G

Guest

Dim s as String
s = Replace(range("J3").Text," ","")
s = s & Range("U3").Text
Activesheet.Parent.SaveAs "C:\MyFolder\" & s & ".xls"
 

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