convert 01/01/06 to 010106

Smithgall

Board Regular
Joined
May 24, 2006
Messages
68
i am trying to name the sheets on file to the value in a cell. I have the code on how to change the sheet name but the value i am trying to use should be a combination of the date and the job number.

So
B2 = 09/08/06 (which is formatted to read Friday, Sep 8, 2006)
B3 = 123654 (job Number)

I want A1 to equal 090806 #123654
and then the sheet will read A1 and equal the same as A1.

As you know the sheet will not accept the dashes or any other characters. Btw i am using the following code to label the sheets


Sub Changetabname()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Activate
ws.Name = Range("$A1").Value
Next
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try using:

ws.Name = Format(Range("$A1").Value,"mmddyy")

As long as the date in A1 is entered as a Date and not a String, this should work.
 
Upvote 0
Sorry, I misread your post a little.

Try this in A1:

=Text(B2,"mmddyy") & "#" & B3

but, you could also do it entirely in VBA not needed to do a calc in A1 by using:

ws.Name = Format(Range("$B2"),"mmddyy") & "#" & Range("B3")
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,178
Members
449,071
Latest member
cdnMech

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