This one is tricky....Macro to save file as cell value x in direct

G

Guest

Hi

Two cells A1 & B2

I am trying to create a Macro to attach to a button to Save an .xls as

"A1".xls in directory R:/SALES/Team 318/"B2"

instead of typing it in all of the time....

Any helpers? Past attempts at this have failed.....the winner will get a big
MVP vote!

Absolute respect

Andy
 
J

Jason Morin

Try something like:

Sub Test()
Dim mypath As String
Dim sfile As Range, sdir As Range

mypath = "R:\SALES\Team 318\"
Set sfile = Sheets("Sheet1").Range("A1")
Set sdir = Sheets("Sheet1").Range("B2")

ThisWorkbook.SaveAs Filename:=mypath & sdir & "\" & sfile

End Sub
 
B

Bob Phillips

ActiveWorkbook.SaveAs Filename:= "R:\SALES\Team 318\" & Range("B1").Value &
"\" & Range("A1").Value & ".xls"

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
G

Guest

How about something like this:

Sub SvFile()

ActiveWorkbook.SaveAs Filename:= _
"R:/SALES/Team 318" & Range("B1").Value _
& "\" & Range("A1").Value & ".xls"

End Sub

tj
 
G

Guest

Andy,
I just copied the filepath from your post--
As the other posts show, if you are on a Windows machine, the slashes from
your filepath are going the wrong way.

tj
 
G

Guest

Thanks Jason. There was a bug in this that I couldnt work out. Thanks for
your help though. The next three worked....
 
G

Guest

thanks for this. It worked.

tjtjjtjt said:
Andy,
I just copied the filepath from your post--
As the other posts show, if you are on a Windows machine, the slashes from
your filepath are going the wrong way.

tj
 
G

Guest

Thanks Bob.....this did the trick as it was the least code for the three
responses. I appreciate your help. Youre not from Brisbane?
 
B

Bob Phillips

Not quite, South Coast of England.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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