VBA Macro Help

juan4412

Board Regular
Joined
Oct 17, 2011
Messages
94
I have a date field in a spreadsheet, and how can I say make the date be date()+1 save then once it save change back to date()?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try like this

Code:
With Range("A1")
    .Value = .Value + 1
    ActiveWorkbook.Save
    .Value = .Value - 1
End With
 
Upvote 0
I want to add in these lines of code but they are bringing in some pretty wierdy compile errors.

Code:
With Range("I4")
    .Value = .Value + 1
    .SaveAs Filename:="C:\Jones\Reports\Daily & ActiveWorkbook.Name & "_" & Format(Date, "mmddyyyy") & ".xls"
    Run "PrintToPDF_MultiSheetToOne_Early"
    .Value = .Value - 1
    End With
And it tells me Object doesn't support this property or method???
on the .SaveAs line
 
Last edited:
Upvote 0
Try

Code:
With Range("I4")
    .Value = .Value + 1
    ActiveWorkbook.SaveAs Filename:="C:\Jones\Reports\Daily" & ActiveWorkbook.Name & "_" & Format(Date, "mmddyyyy") & ".xls"
    Run "PrintToPDF_MultiSheetToOne_Early"
    .Value = .Value - 1
End With
 
Upvote 0
That code runs through the motions but doesn't actually modify the date. I just double checked and it isn't date() but it's Today() that is in the cell. Does that make a difference as for the VBA that should be used to change it?
 
Upvote 0
Maybe like this

Code:
With Range("I4")
    .Formula = "=TODAY() + 1"
    ActiveWorkbook.SaveAs Filename:="C:\Jones\Reports\Daily" & ActiveWorkbook.Name & "_" & Format(Date, "mmddyyyy") & ".xls"
    Run "PrintToPDF_MultiSheetToOne_Early"
    .Formula = "=TODAY()"
End With
 
Upvote 0
Same error as before with that code. Object doesn't support this property or method???
on the .SaveAs line
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

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