Date Field Format Detection

Gives

Board Regular
Joined
Aug 22, 2006
Messages
160
How can I detect the Date format of a given cell?

I have a macro to create pivot tables from a column data in a spreadsheet. The column titles are used in data validation list on a separate spreadsheet. The user selects which fields to use as rowfields, columnfields, pagefields, and datafields from the validation drop-down lists. Some columns have dates as the column title; Actual entry is 1/1/2009 but formating changes to Jan-09. The validation list displays Jan-09 in the worksheet and 1/1/2009 in the fx toolbar. I use activecell.offset.value to get the validation list field which retrieves 1/1/2009. The With pivotfields(activecell.offset.value) statement fails because it can't find 1/1/2009. When I substitute Jan-09 in the pivotfields statement it works fine. So.....

How can I detect the original Date format in the Table and then set activecell.offset.value to that format so it will find the column?
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
You can get the format like this

Code:
MsgBox ActiveCell.NumberFormat
 
Upvote 0

Forum statistics

Threads
1,203,455
Messages
6,055,541
Members
444,794
Latest member
HSAL

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