It's a date! ... or could be with help

MrChuckles69

New Member
Joined
Apr 2, 2020
Messages
8
Office Version
  1. 365
Platform
  1. Windows
  2. 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
 
I asked as already on this thread there are three diff ways ... and (to me) its ambiguous where the code slots in and what comes out ...
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
I mean like this:
VBA Code:
Sub Picture1_Click()
Dim Path As String
Dim FileName1 As String
Dim Filename2 As String
Path = "/Users/me/Documents/mine/"
FileName1 = Range("D2")
Filename2 = Application.WorksheetFunction.Text(range("H6").Value,"[$-en-GB]dd mmmm yyyy")
ActiveWorkbook.SaveAs FileName:=Path & FileName1 & Filename2 & ".xlsx", FileFormat:=xlOpenXMLWorkbook
End Sub
Actually you can use any format. if it is only numbers that you need you can do it like this:
VBA Code:
Sub Picture1_Click()
Dim Path As String
Dim FileName1 As String
Dim Filename2 As String
Path = "/Users/me/Documents/mine/"
FileName1 = Range("D2")
Filename2 = Format(range("H6").Value,"yyyy-mm-dd")
ActiveWorkbook.SaveAs FileName:=Path & FileName1 & Filename2 & ".xlsx", FileFormat:=xlOpenXMLWorkbook
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,082
Messages
6,128,709
Members
449,464
Latest member
againofsoul

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