Best way to pass a named range to a macro?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,532
Office Version
  1. 365
Platform
  1. Windows
I am working on a macro that will analyze data in a table and some data outside the table or possibly in a second table. What's the best way to pass those ranges to the macro?

I prefer to call the macro using a button form control. I've done that several times. But as far as I know, there is no way to pass any parameters (arguments) that way.

Thanks for any help.
 
In which module in the addin is the WtdRtg macro?
It's in the "WeightedRating" module.

I changed the text to:

'C:\Users\Wes C\AppData\Roaming\Microsoft\AddIns\My Add-Ins.xlam\WeightedRating'!'WtdRtg("TblParms", "TblData")'

That gets the same error message.
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I no longer say something cannot be done as there is always someone out there that will tell you otherwise

I have never used a forms button to call code in that manner & cannot immediately give you any informed guidance - maybe another can.
I am on granddad (school run) duties today but If find a moment I will have a play and if have any success, will come back.

Dave
Absolutely put that granddad duty first. My favorite Irish saying is,
Children are the rainbow of life.
Grandkids are the pot 'o gold.
And don't you dare spoil them . . . any more than they are worth.
 
Upvote 0
That's the wrong place for the module name - it would be:

Code:
'C:\Users\Wes C\AppData\Roaming\Microsoft\AddIns\My Add-Ins.xlam'!'WeightedRating.WtdRtg("TblParms", "TblData")'
 
Upvote 0
Curiously, although the syntax works with one argument, I cannot as yet get it to work with more than that.
 
Upvote 0
Curiously, although the syntax works with one argument, I cannot as yet get it to work with more than that.
I got it to work with just one argument, too. Thanks.

Since they are both strings, I can pass them both as one space-delimited string. I'll do that until a way of found to pass more than one argument.

But I am now exhausted. I'll check back in the morning. Nitey-nite. 🥱😴😴
 
Upvote 0
Using:

Code:
'C:\Users\username\AppData\Roaming\Microsoft\AddIns\My Add-Ins.xlam'!'WtdRtg("TblParms", "TblData")'

should work.
Rory,

I am marking your post as the solution. I tried several versions of the ones in the Excel Off The Grid page, but could not get any of them to work. I thought I had tried your solution, but apparently not. It works perfectly.

Thanks. I would never have figured it out n my own! 🤨🤔😣
 
Upvote 0

Forum statistics

Threads
1,215,024
Messages
6,122,729
Members
449,093
Latest member
Mnur

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