Date to label?

Jaymond Flurrie

Well-known Member
Joined
Sep 22, 2008
Messages
921
Office Version
  1. 365
Platform
  1. Windows
I would like to have a date in label in a way like "8/2011". How do I do the numberformat to there?

I tried like:
Code:
            Range("A1") = Date
            Range("A1").NumberFormat = "m/yyyy"
            lblDate.Caption = CStr(Range("A1").Value)

but that doesn't seem to work, it just gives the current date "8/8/2011".

Oh and this doesn't have to be in a label. Any container is good enough, as long as I just can copy it on top of a chart (because that way I can get the date exactly where I want on top of a chart (I print the chart out and destroy it, so even if this is pretty ugly way to do it, it still would work).
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Change Value to Text or use this:
Code:
lblDate.Caption = Format(Range("A1").Value, "m/yyyy")
 
Upvote 0
Try this for your label assignment instead...

Code:
lblDate.Caption = Range("A1").Text
 
Upvote 0
Do you really need to use A1?
How about:
Code:
lblDate.Caption = Format(Date, "m/yyyy")

Hope it helps.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,835
Members
452,947
Latest member
Gerry_F

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