excel - How to insert a date (based on a cell reference) in file Title? -
i have macro saves excel file pdf, insert date within saved file name based on particular cell reference in workbook in "yyyy-mm-dd" date format.
the specific sheet in workbook want reference titled "variables , macros"; particular cell contains date cell b4 within sheet.
the current recorded macro below:
activesheet.exportasfixedformat type:=xltypepdf, filename:= _ "z:\regional weekly report\11 may\forecast template\fiscal 2015 weekly projections 2015-05-24.pdf" _
i ideally keep section static: z:\regional weekly report\11 may\forecast template\fiscal 2015 weekly projections
, add cell reference date after; such & text('variables , macros'!b4,"yyyy-mm-dd"
. i've looked @ similar posts (i.e. adding range("b4").value
) nothing seems working, i'm missing something.
you try this
excel 2010
sub saveas() dim savepath string dim saveas string dim filename string dim sdate string '// save path savepath = "z:\regional weekly report\11 may\forecast template\" '// file name filename = "fiscal 2015 weekly projections " '// format on "b4" yyyy-mm-dd sdate = format(sheets("sheet1").range("b4"), "yyyy-mm-dd") '// save file name & date & .pdf saveas = filename & sdate & ".pdf" application.displayalerts = true '// export active sheet pdf activesheet.exportasfixedformat type:=xltypepdf, filename:= _ savepath & saveas application.displayalerts = true end sub
Comments
Post a Comment