VBA with Cell Ref that includes a Date issue

Dazzybeeguy

Board Regular
Joined
Jan 6, 2022
Messages
72
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I have the following that Works fine, L8 is a cell with Text, however I want it to use Cell W4 which has the formula =Lists!E2&" w/e"&" "&TEXT(O10,"ddd-dd-mmm-yyyy") The formula would return BB w/e Sun-19-Feb-2023

When I try it with W4 as the cell with the value I get Run Time Error '-2147018887 (80071779)': Document Not Saved

Any ideas how I can get the Excel file to export as a PDF with the date in the name ?

Sub SaveAsPD4()
Dim filename As String
filename = "C:\Users\dazzy_zlpocbd\OneDrive\Desktop\Diary Logs\" & Range("L8").Value
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
filename, Quality:=xlQualityStandard, IncludeDocProperties _
:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi,

In your filename, you could test to replace Range("L8").Value
by
Evaluate("=Lists!E2&"" w/e ""&TEXT(O10,""ddd-dd-mmm-yyyy"")")
 
Upvote 0
The forward slash "/" is an illegal character in a file name.

1676272594038.png
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,854
Members
449,051
Latest member
excelquestion515

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