MrChuckles69
New Member
- Joined
- Apr 2, 2020
- Messages
- 8
- Office Version
- 365
- Platform
- Windows
- MacOS
A friend asked for help with VBA ... getting a file to save (invoices) based on clicking an image and saving the document based on two cell values
The first one is the customer name and the second is a date
I took on the challenge and googled and ... sometimes it worked, sometimes not, worked on mine, didnt on his etc ...
The date cell was a problem as it didnt work unless it was a text cell, so we ran with that for now
I'd like to finish the job but despite looking on google, Mr Excel and others ... most answers arent quite the same ... looking at 'TODAY' as a data and not teh cell
I'm stuck!
This is the code that saves a file at the moment ... might not be pretty or perfect and so if theres an easier way ... all ears!
D2 is the cell with the client name and H6 has a date in it
Thank you guys!
Sub Picture1_Click()
Dim Path As String
Dim FileName1 As String
Dim Filename2 As String
Path = "/Users/me/Documents/mine/"
FileName1 = Range("D2")
Filename2 = Range("H6")
ActiveWorkbook.SaveAs FileName:=Path & FileName1 & Filename2 & ".xlsx", FileFormat:=xlOpenXMLWorkbook
End Sub
The first one is the customer name and the second is a date
I took on the challenge and googled and ... sometimes it worked, sometimes not, worked on mine, didnt on his etc ...
The date cell was a problem as it didnt work unless it was a text cell, so we ran with that for now
I'd like to finish the job but despite looking on google, Mr Excel and others ... most answers arent quite the same ... looking at 'TODAY' as a data and not teh cell
I'm stuck!
This is the code that saves a file at the moment ... might not be pretty or perfect and so if theres an easier way ... all ears!
D2 is the cell with the client name and H6 has a date in it
Thank you guys!
Sub Picture1_Click()
Dim Path As String
Dim FileName1 As String
Dim Filename2 As String
Path = "/Users/me/Documents/mine/"
FileName1 = Range("D2")
Filename2 = Range("H6")
ActiveWorkbook.SaveAs FileName:=Path & FileName1 & Filename2 & ".xlsx", FileFormat:=xlOpenXMLWorkbook
End Sub