Procedure to pass a dynamic named range

djpratt

New Member
Joined
Jun 29, 2010
Messages
3
I have a table and it named emTbl and a macro to select it.
Sub SelectEmTbl()
‘Select EmTbl
Application.Goto Reference:="EmTbl"
End Sub
This works fine but I’m wanting a generic procedure like
SelectRange(EmTbl)
So, how do you modify the procedure to pass a dynamic name range?
It looks easy but I can’t get it.
TIA
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
When I tried Range(EmTBl).Select I got an error. But this is not what I'm looking for.
Application.Goto Reference:="EmTbl" Does work for me. It selects a table named EmTbl. What I want to learn to do is to put that command in a macro and pass the name to it. Something like
SelectRange(EmTbl)

Sub SelectRange(Byval rRng as Range)
Application.Goto Reference:=rRng
End Sub

What do I need to do to get this macro to work? It looks like it would be easy but I can't get it.
 
Upvote 0
I solved my problem. The named range is passed as a string, not a range. So this is all I had to do.

Sub SelectRange(Byval sRng as String)
Application.Goto Reference:=sRng
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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