Automated Pivot Table

SteveO59L

Well-known Member
Joined
Apr 21, 2004
Messages
7,899
I am using the following as part of an automated pivot table.

ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("19-May-03"), "Count of 19-May-03", xlCount
ActiveWorkbook.ShowPivotTableFieldList = False

The 19-May-03 value can change and therefore, I would like to set this value from the value in a specific cell (u7).

The problem being is that when I assign the value in u7 to a variable within the macro, it assumes a format of dd/mm/yy, rather than dd-mmm-yy that the data is in.

Is there a way to convert the date format, within the code ?

TIA

:confused:
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hope this helps:

Dim stringDay As String
Dim stringMth As String
Dim stringYr As String
Dim variableString As String
Dim myDate As Date

myDate = 'your variable'

stringDay = Day(myDate)
stringMth = MonthName(Month(myDate))
stringYr = Year(myDate)
variableString = stringDay & "-" & stringMth & "-" & stringYr
 
Upvote 0
Ty,

That worked fine for setting the variable, but the

"PivotFields("19-May-03"), "Count of 19-May-03", "

still wont accept the variable.

Thanks anyway
 
Upvote 0

Forum statistics

Threads
1,203,502
Messages
6,055,772
Members
444,822
Latest member
Hombre

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