Text Equivalent of A Formatted Date

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,022
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I have this piece of code ....
Code:
       If tcol = 8 Then
            .Cells(irw, tcol).Value = Format(bkg_date - 1, "dd-mmm")
            irw = irw + 1
        End If

That places a date value in the cell defined by .cells(irw,tcol).
This cell is normally, and must remain, as text. So, when the date value gets placed, it appears as that date's serial.
Since the date won't be used for any calculations, there is no reason why it can't be the text equivalent of "dd-mmm". What can I do to place that text equivalent of "dd-mmm" in that cell?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
67,892
Office Version
  1. 365
Platform
  1. Windows
Try
VBA Code:
.Cells(irw, tcol).NumberFormat = "@"
.Cells(irw, tcol).Value = Format(bkg_date - 1, "dd-mmm")
 
Solution

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,022
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Very nice! Thanks Fluff!!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
67,892
Office Version
  1. 365
Platform
  1. Windows
Glad to help & thanks for the feedback
 
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,697
Messages
5,765,982
Members
425,320
Latest member
Galin

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
Top