Rename with part of string from named range

Want2BExcel

Board Regular
Joined
Nov 24, 2021
Messages
112
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to figure out how to only use part of the string to rename sheets. I have this but the result is January2022. I want it to be Jan.22. Can someone help me to figure it out...

Sub Copy_3MdrTemplate_Sheet()
Dim sh As Worksheet
Dim answer As Integer
s = [ScMonth]
y = [ScYear]


VBA Code:
answer = MsgBox("BEMÆRK! Du vil ikke kunne ændre måned på det nye ark" & vbCrLf & "Er måned og år, som du ønsker?" & vbCrLf & "Er du sikker på du ønsker at forsætte?", vbQuestion + vbYesNo, "Opret nyt månedsark")
    If answer = vbYes Then
        Else: Exit Sub
    End If
 
          On Error Resume Next
          'check sheet exists already
          Set sh = Sheets(s & y)
          On Error GoTo 0
          If Not sh Is Nothing Then MsgBox "Den måned findes allerede. Prøv igen", vbCritical: Exit Sub

     'copy your template before that sheet
     Sheets("Template").Copy before:=Sheets("DataSheet")
     With ActiveSheet
        'rename sheet
          .Name = s & y
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi
What about
VBA Code:
  .Name = Left(s, 3) & " & y"
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

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