Range Name

mbachi

Board Regular
Joined
Nov 30, 2005
Messages
112
I would like to add a named range to a macro that I have. The problem I have is that I want the name of the range to be based on a variable. I have defined the variables at the top of the data and what I need to do is to add a name range based on the CurMonth and also MC or SY. I have been unable to find a way of doing this so far. If I haven't provided enough info, please let me know



--Global Variables--
Dim MC As Worksheet ' MC01 Data
Dim SY As Worksheet 'SY01 Data
Dim CurMonth(1 To 12) As String

---Initial Part of Macro--
Set MC = Workbooks("Book3.xls").Worksheets(CurMonth(i) & " MC01")
Set SY = Workbooks("Book3.xls").Worksheets(CurMonth(i) & " SY01")

---
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
These are two snippets I got from the board before:

Sub createmyname()
Sheet2.Range("A1", Sheet2.Range("A65536").End(xlUp)).Name = "Daddy"
End Sub

Sub MyRange()
Range(ActiveCell, ActiveCell.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="Baby", _
RefersTo:="='Sheet1'!" & Range(ActiveCell, ActiveCell.End(xlDown)).Address
End Sub
 
Upvote 0

Forum statistics

Threads
1,226,222
Messages
6,189,706
Members
453,566
Latest member
ariestattle

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