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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try like this

Code:
With Range("A1")
    .Value = .Value + 1
    ActiveWorkbook.Save
    .Value = .Value - 1
End With
 
Upvote 0

juan4412

Board Regular
Joined
Oct 17, 2011
Messages
94
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

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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

juan4412

Board Regular
Joined
Oct 17, 2011
Messages
94
ADVERTISEMENT
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

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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

juan4412

Board Regular
Joined
Oct 17, 2011
Messages
94
ADVERTISEMENT
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,195,749
Messages
6,011,436
Members
441,614
Latest member
TiaGtz

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
Top