get column number from a named range

divuraj

Board Regular
Joined
Sep 28, 2006
Messages
75
Hi,

this is an urgent assignment i am working on and i am stuck with a vba code.

i have a named range "Analogues" which refers to D4 now, but the user can add or delete columns, so i am trying to use named range in my code.

i am trying to get the column position of this cell by

ColNum = Range("Analogues").column which is giving me a Range Global oject failed error.

can anyone please help.

Thanks,
div.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
That line of code appears to be okay. Perhaps you need to tell us more about how the named range is defined, what the rest of your code is, where that code is placed etc.
 
Upvote 0
Thanks for a quick response.

This is on click of a button within a form:

Public Sub cmdPre_Click()
Dim ColNum As Variant

ColNum = Range("Analogues").Column
Call ExportToAnalogues("Analogues")

End Sub

after this i am calling another procedure which works fine. Thanks for any help !
 
Upvote 0
What version of Excel are you using?

How is your named range defined?
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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