ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Convert worksheet string name to date format in cell (https://www.excelbanter.com/excel-worksheet-functions/241673-convert-worksheet-string-name-date-format-cell.html)

Sabosis

Convert worksheet string name to date format in cell
 
Hello-

I have a workbook that will always have a sheet name such as 082509. I
want to have cell J2 take that string and convert to a MM/DD/YY
format. I tried the following, but it did not work:

Range("J2").Select
ActiveCell.FormulaR1C1 = DateValue(Format(Range(Worksheet
(1)).Value, "00/00/00"))

Any ideas?

Thanks

Dave Peterson

Convert worksheet string name to date format in cell
 
maybe...

I'd use:

With ActiveSheet.Range("J2")
.NumberFormat = "mm/dd/yy" 'whatever you want
.Value = DateValue(Format(Worksheets(1).Name, "00/00/00"))
End With



Sabosis wrote:

Hello-

I have a workbook that will always have a sheet name such as 082509. I
want to have cell J2 take that string and convert to a MM/DD/YY
format. I tried the following, but it did not work:

Range("J2").Select
ActiveCell.FormulaR1C1 = DateValue(Format(Range(Worksheet
(1)).Value, "00/00/00"))

Any ideas?

Thanks


--

Dave Peterson

Sabosis

Convert worksheet string name to date format in cell
 
On Sep 3, 6:57*pm, Dave Peterson wrote:
maybe...

I'd use:

With ActiveSheet.Range("J2")
* * .NumberFormat = "mm/dd/yy" 'whatever you want
* * .Value = DateValue(Format(Worksheets(1).Name, "00/00/00"))
End With

Sabosis wrote:

Hello-


I have a workbook that will always have a sheet name such as 082509. I
want to have cell J2 take that string and convert to a MM/DD/YY
format. I tried the following, but it did not work:


Range("J2").Select
* * ActiveCell.FormulaR1C1 = DateValue(Format(Range(Worksheet
(1)).Value, "00/00/00"))


Any ideas?


Thanks


--

Dave Peterson


Dave, thanks for the help!


All times are GMT +1. The time now is 04:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com