Name Ranges = Worksheet tab name

JPZZLE

New Member
Joined
Nov 11, 2009
Messages
1
I haven't been able to find a code to name a range in each worksheet with the name of the worksheet. Would this be possible? I have the below so far. Am I heading in the right direction? Do I need to do something else?

Sub Add_ALL_Budgets()
Dim Awb As Workbook
Dim ws As Worksheet


Set Awb = ThisWorkbook


For Each ws In Awb.Worksheets
If UCase(Right(Trim(ws.Name), 6)) = "BUDGET" And _
UCase(Left(Trim(ws.Name), 3)) <> "158" Then
ws.Activate
Range("T1").Select
Selection.Value = "WORKS!" 'this was to check it selected the worksheets I wanted
Range("T8:AE215").Name = ' What do I do here?
ElseIf UCase(Right(Trim(ws.Name), 6)) = "BUDGET" And _
UCase(Left(Trim(ws.Name), 3)) = "158" Then
ws.Activate
Range("T1").Select
Selection.Value = "WORKS!"
Range("Z8:AK215").Name = UCase(ws.Name) 'This doesn't work
End If
Awb.Activate
Next ws
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
This is a no-no as I have been taught. You never want to use named ranges that match any other Excel object... I wouldn't use a name that matches sheetname or a cell reference.
 
Upvote 0

Forum statistics

Threads
1,215,619
Messages
6,125,872
Members
449,267
Latest member
ajaykosuri

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