Format range

vbaNewby

Board Regular
Joined
Jan 26, 2011
Messages
138
Hello I have a range variable named rng.

I set it. I then want to format it with DD/MM/YYYY

I'm getting a type mismatch using this:

Code:
'set range
Set rng = ....

rng = Format(rng, "DD/MM/YYYY")

Help!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try

Code:
Rng.NumberFormat = "DD/MM/YYYY"

Hi Vog,

Thanks for the reply. This runs without error but it does not change the format of the range.

What i am doing is setting the range, use Rng.NumberFormat = "DD/MM/YYYY"
, then rng.Copy, change sheets and paste in the range. On my pasted sheet though, its not formatted...?
 
Upvote 0
Try

Code:
Rng.NumberFormat = "DD/MM/YYYY"

VoG,

Also after the pasting of the range, I look at the cell and it is formatted as a custom format with DD/MM/YYYY

But yet it still looks like this: Jan 1, 2010.

Is this because the original contents of the rng are not date formatted and just simple text???
 
Upvote 0
I think that you have text dates, not Excel dates. You cal check like this

=ISNUMBER(A1)

which will return True for a date, False for text.
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,799
Members
452,943
Latest member
Newbie4296

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