Cant sort dates in table

Peltz

Board Regular
Joined
Aug 30, 2011
Messages
87
Hi there

Ive written a code that timestamp a certain cell in a table:
Code:
ws2.ListObjects("Table1").DataBodyRange(i, 1).Value = Format(Now(), "dd.mm.yyyy")

However, when trying to filter the dates in the table they are not recognized as dates. The whole collumn in the sheet is formatted as dates beforehand as well. If i try to change formatting the cell to, say (dd.mm.yy), nothing happens (allthough the other dates in the table change).

Any idea on whats going on here?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
That is because the Format function actually returns a Text value, not a Date value (it converts it from Date to Text).
What you should do is to write the value as a Date like this:
Code:
ws2.ListObjects("Table1").DataBodyRange(i, 1).Value = Now()"dd.mm.yyyy")
And simply format the column as "dd.mm.yyyy"
 
Last edited:
Upvote 0
Ahhh, there you go.

I changed the code to
Code:
[/COLOR][COLOR=#333333]ws2.ListObjects("Table1").DataBodyRange(i, 1).Value = Now()[/COLOR][COLOR=#333333]

All is as it should. Thank you!
 
Upvote 0
You are welcome!
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

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