With / End With:- Changing property of the Variable to be in date Format or Number format

SPiercy

New Member
Joined
Oct 17, 2010
Messages
16
Hi,

Im currently using With / End With statements to apply formulas or link in data via a named range.

What I want to be able to do is change the property of what I'm linking in to be in date format.

For example I have the code
Set FiscalYrPrd = Range("AG7:AH" & .Range("AA" & .Rows.Count).End(xlUp).Row)
With FiscalYrPrd
.Formula = "=C7"
.Value = .Value
End With

my understanding if that your changing the property of the variable to be a formula and then a value, therefore is it possible to change the format property of the range so its in date format (dd/mm/yy)?

Any help would be greatly appreciated!
In addition - same request but in numerical format with zero d.p?

Many thanks in advance.

Rgd,

SPiercy
 
Try

Code:
With FiscalYrPrd
    .Formula = "=C7"
    .Value = .Value
    .NumberFormat = "dd/mm/yy"
End With
 
Upvote 0
Thanks for that.
And for a number to be in the format 1234 (i.e no dp and no thousand seperator)
it would be
.Numberformat = "0"
Is this correct.
 
Upvote 0
Yes, that should work. The easiest way to get number format code is to record a macro whilst changing the format manually.
 
Upvote 0

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