Rename a Sheet

jn_24

New Member
Joined
Apr 1, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi, I want to rename my Sheet1 to PythonAI and Sheet2 to WebDev
Can you edit the code below for me to not have an error. Thanks!

VBA Code:
Private Sub Worksheet_Activate()
Dim LR As Long
LR = ActiveSheet.Cells(1, 1).CurrentRegion.Rows.Count
Range("A2:C" & LR).Select
Selection.AutoFilter
    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:=Range _
        ("B2"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
     Selection.AutoFilter


    Range("C2").Select
    ActiveCell.Formula = "=RANK.AVG(B2,$B$2:$B$28,0)"

    Range("C2").Select
    Selection.AutoFill Destination:=Range("C2:C" & LR), Type:=xlFillnormal

    Range("C2:C" & LR).Select
     Range("C2").Select

     End Sub
 
Last edited by a moderator:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Your code has no bearing on renaming sheets as far as I can see.
Maybe just explain in a concise manner what you would like to achieve.
 
Upvote 0
Your code has no bearing on renaming sheets as far as I can see.
Maybe just explain in a concise manner what you would like to achieve.
I think the OP simply wants the existing code altered so that it does not throw an error if activated after the sheets have been renamed.

@jn_24
Welcome to the MrExcel board!

When posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug & copy. My signature block below has more details. I have added the tags for you this time. 😊
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,642
Members
452,663
Latest member
MEMEH

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