ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Work sheets tab names only replace part ot the present name (https://www.excelbanter.com/excel-worksheet-functions/244537-work-sheets-tab-names-only-replace-part-ot-present-name.html)

John Augustein

Work sheets tab names only replace part ot the present name
 
The work book has 23 sheets all linked to 1. I want to put the parts to change too.
A1 = 2482
A2 = CH5

The following is a current tab name.

2481~2481 SN22 CODEGK4

I need everything to stay the same except after the change I need it to say

2482~2482 SN22 CODECH5

Thanks in advance.
Augie

EggHeadCafe - Software Developer Portal of Choice
Review: Improving .NET Application Performance
http://www.eggheadcafe.com/tutorials...ng-net-ap.aspx

Teethless mama

Work sheets tab names only replace part ot the present name
 
=A1&"~"&A1&" SN22 CODE"&A2


"John Augustein" wrote:

The work book has 23 sheets all linked to 1. I want to put the parts to change too.
A1 = 2482
A2 = CH5

The following is a current tab name.

2481~2481 SN22 CODEGK4

I need everything to stay the same except after the change I need it to say

2482~2482 SN22 CODECH5

Thanks in advance.
Augie

EggHeadCafe - Software Developer Portal of Choice
Review: Improving .NET Application Performance
http://www.eggheadcafe.com/tutorials...ng-net-ap.aspx


Rick Rothstein

Work sheets tab names only replace part ot the present name
 
I assume you want to change the actual worksheet name, correct? If so...

You didn't say whether the number in A1 is always going to be four digits
long or not; nor did you day whether the value in A2 will always be three
characters long or not. This code should work for any case...

Sub ChangeTabName()
Dim S() As String
If Range("A1").Value < "" And Range("A2").Value < "" Then
S = Split(ActiveSheet.Name, , 2)
S(0) = Range("A1").Value & "~" & Range("A1").Value
S(1) = Left(S(1), InStrRev(S(1), "code", , vbTextCompare) _
+ 3) & Range("A2").Value
ActiveSheet.Name = Join(S)
End If
End Sub

--
Rick (MVP - Excel)


"John Augustein" wrote in message ...
The work book has 23 sheets all linked to 1. I want to put the parts to
change too.
A1 = 2482
A2 = CH5

The following is a current tab name.

2481~2481 SN22 CODEGK4

I need everything to stay the same except after the change I need it to
say

2482~2482 SN22 CODECH5

Thanks in advance.
Augie

EggHeadCafe - Software Developer Portal of Choice
Review: Improving .NET Application Performance
http://www.eggheadcafe.com/tutorials...ng-net-ap.aspx




All times are GMT +1. The time now is 09:56 PM.

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