Naming Worksheet with Two Range Values

Shiseiji

Board Regular
Joined
Oct 23, 2009
Messages
214
Office Version
  1. 2019
Platform
  1. Windows
Hi all, time to ask for help. What's the error please:

VBA Code:
Sub m_NamePastAdmin()
    '
    Application.DisplayAlerts = False
    Application.DisplayStatusBar = False
    Application.ScreenUpdating = False
'
    ws_3Admin1.Activate
'
    Dim LastCol                     As Integer
    Dim LastRow                     As Long
    Dim ThisWsName                  As Name
    Dim PastAdminWsDate             As Range
    Dim PastAdminWsName             As Range
    Dim ThisWs                      As Worksheet
    Dim ThisWb                      As Workbook
    '
    Set ThisWb = ActiveWorkbook
    Set ThisWs = ActiveSheet
    '
    With ThisWs
        LastRow = .Cells(Cells.Rows.Count, "A").End(xlUp).Row
        LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
        Cells(Rows.Count, "A").End(xlUp).Name = "PastAdminWsDate"
        Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Name = "PastAdminWsName"
        Range("PastAdminWsName").Value = "Past Admin "
        ws_3Admin1.Name = Range(PastAdminWsName) & Range(PastAdminWsDate)
      Application.ScreenUpdating = True
      Application.StatusBar = False
End With 'ThisWs
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
did you try using quotes as shown below in both ranges?

ws_3Admin1.Name = Range("PastAdminWsName") & Range("PastAdminWsDate")



.
 
Last edited:
Upvote 0
Solution
Thanks, I "Thought" I had, but obviously hadn't. I get confused on when the quotes are needed and when they aren't. Fooled with this for 4 hours :mad: and lost track of how many different things I'd tried. Had started with trying to set ranges as I won't need them after the worksheet is named and then bounced all over the place.

Really appreciate it. (y)

Ron
 
Upvote 0
Happens with the best of us.

Glad to know it worked for you eventually. thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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