Convert Worksheet Name to Date in a Cell

singincpa

New Member
Joined
Nov 7, 2014
Messages
11
Hi,

I am attempting to automate some data entry in Excel. I have a workbook, and each sheet's name is a 6-digit date. I want to create a formula to add that sheet's name to a specific cell, but in a standard date format (m/dd/yyyy). For example, a sheet is named 083019. I want cell D2 to read the sheet name and convert it to the date 8/30/2019. Is this possible?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi,
It's impossible using excel formulas. However, this can achieved with VBA macro or by own developed function. Anyway, VBA programming is required.

Regards,
Sebastian
 
Upvote 0
Paste this code into the code window of your ThisWorkbook Object
Then on a selected blank cell Double-Click it. HTH, Jim

Code:
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True
Target.Value = Left(Sh.Name, 2) & "/" & Mid(Sh.Name, 3, 2) & "/" & "20" & Right(Sh.Name, 2)
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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