save file based on 4 cell refs

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
675
Office Version
  1. 365
Platform
  1. Windows
hi,

I can save the file based on 1 cell ref, but need to also use 3 others?

cells ref :-

B4 = name
e7 = james
w2 = ID Number
w3 = 008

file name
save as
c:\data\namejamesidnumber008.xls

hope this makes sense & thank you :}
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi let me know if the code below work

Sub Test()


Dim Path1 As String
Dim Path2 As String
Dim Path3 As String
Dim Path4 As String
Dim myfilename As String




Path = "C:\data"
Path1 = Range("B4")
Path2 = Range("E7")
Path3 = Range("W2")
Path4 = Range("W3")


ActiveWorkbook.SaveAs Filename:=Path & Path1 & Path2 & Path3 & Path4 & ".xls", FileFormat:=xlNormal




End Sub

For the path you will have to copy the specific location you want to save it to
 
Upvote 0
Hi let me know if the code below work

Sub Test()


Dim Path1 As String
Dim Path2 As String
Dim Path3 As String
Dim Path4 As String
Dim myfilename As String




Path = "C:\data"
Path1 = Range("B4")
Path2 = Range("E7")
Path3 = Range("W2")
Path4 = Range("W3")


ActiveWorkbook.SaveAs Filename:=Path & Path1 & Path2 & Path3 & Path4 & ".xls", FileFormat:=xlNormal




End Sub

For the path you will have to copy the specific location you want to save it to


good morning,

thanks for your code & FANTASTIC, it works a treat.:beerchug:

Have a great day
KR
Trevor3007
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top