Forum Discussion

Raj_123's avatar
Raj_123
Brass Contributor
Sep 03, 2020
Solved

I want to rename all the sheet tabs of an excel

Hi If there are sheet 1, sheet 2, sheet3 , sheet4 and sheet5 and i have deleted the sheet 4 tab...now the sheets in excel would be sheet1, sheet2, sheet3 and sheet5..( please observe there would be n...
  • Raj_123's avatar
    Raj_123
    Sep 04, 2020
    Thank you friend.

    I have used the above code and it actaully worked but issue arised is as per our procedures we renumber and rename the sheets using a macro button then it would look like this 1-Rob1, 2-Rob2,...10-Rob10,....100-Rob100 now i have inputtted the character as 5 for the old and renamed the result came out missed from10-Rob10 (bRaj10) bcoz it has 6 characters the and the 100-Rob10 has 7chartacters (obRaj100).

    I have used the below code but the lapse is it is changing the serial number but it ibrilliantly changes the sheet name just by asking new code....can we adjust the below code accordingly.



    Sub ChangeWorkSheetName()

    Dim Rng As Range

    Dim WorkRng As Range

    On Error Resume Next

    newName = Application.InputBox(“Name”, xTitleId, “”, Type:=2)

    For i = 1 To Application.Sheets.Count

    Application.Sheets(i).Name = newName & i

    Next

    End Sub

Resources