Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88066

How do I use WorksheetFunction.Text to convert a date from M/D/YY to YYYY-MM-DD?

$
0
0

I have a date in cell B7 in my worksheet that is formated as 9/1/2019, I want to convert it to a text string in the format YYYY-MM-DD or 2019-09-01. I tried using WorksheetFunction.Text and searched the web for examples, but my code just generated a "True" result instead of a reformatted date.

Dim FormattingValue As String
Dim FormattingResult As String

FormattingValue = WS1.Range("B7").Select

FormattingResult = WorksheetFunction.Text(FormattingValue, "YYYY-MM-DD")

Debug.Print FormattingResult

The Debug.Print returns the value "True" and not a date in the YYYY-MM-DD format.


Viewing all articles
Browse latest Browse all 88066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>