Macro Help!

JFORTH97

New Member
Joined
Nov 26, 2020
Messages
10
Office Version
  1. 365
Platform
  1. MacOS
Hi

I'm trying to create a Macro so from my worksheet by pressing a button it will export it as a PDF, but then save it based on 3 cell Values, C4, C6 & C8.

C4 is a name
C6 is a name
C8 is a date

I'm wanting it to save to a specific file location to: C:\Users\Vector\Google Drive\H_O Office\Timesheets for Head Office

Can anyone help me, would be much appreciated!
 
Could you post the actual contents of C4, C6 and C8?
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
IMG_0055.jpg
 
Upvote 0
"HO/O Office" contains the reserved character "/" which cannot be used in a file name. This macro will replace it with a hyphen:
VBA Code:
Sub SavePDF()
   Dim Pth As String
    Pth = "C:\Users\Vector\Google Drive\H_O Office\Timesheets for Head Office\"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Pth & Range("C4") & " " & Replace(Range("C6"), "/", "-") & " " & Format(Range("C8"), "dd-mm-yyyy") _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=False
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

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