ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting todays date (https://www.excelbanter.com/excel-programming/421666-selecting-todays-date.html)

J.W. Aldridge

Selecting todays date
 
Any way to rewrite the code below to choose whatever the current date
is instead of a specific date? =today().


ActiveSheet.PivotTables("PivotTable1").PivotFields
("DATE").CurrentPage = _
"12/22/08"


I am trying to set up the sheet code to refresh the two pivot tables
on the page and then change the dates to whatever the current date
whenever the sheet is selected.

thanx

JLGWhiz

Selecting todays date
 
This should give you the current date in your systems default format.

ActiveSheet.PivotTables("PivotTable1").PivotFields ("DATE"). _
CurrentPage = Date



"J.W. Aldridge" wrote:

Any way to rewrite the code below to choose whatever the current date
is instead of a specific date? =today().


ActiveSheet.PivotTables("PivotTable1").PivotFields
("DATE").CurrentPage = _
"12/22/08"


I am trying to set up the sheet code to refresh the two pivot tables
on the page and then change the dates to whatever the current date
whenever the sheet is selected.

thanx


J.W. Aldridge

Selecting todays date
 
Thanx!

That works...


One question though...

How to change the format on that...?

My current date format is ##-Mmm.
The default is mm/dd/yyyy.

Although the date populates in the pivot table field, it does not
actually work because of the difference in format.

Thanx again

Dave Peterson

Selecting todays date
 
ActiveSheet.PivotTables("PivotTable1").PivotFields ("DATE").CurrentPage _
= format(Date,"dd-mmm")

Is ##-Mmm the day number (2 digits) and the abbreviated month name?

"J.W. Aldridge" wrote:

Thanx!

That works...

One question though...

How to change the format on that...?

My current date format is ##-Mmm.
The default is mm/dd/yyyy.

Although the date populates in the pivot table field, it does not
actually work because of the difference in format.

Thanx again


--

Dave Peterson


All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com