structured reference: using column name in header row to identify column

rny1mrxl

New Member
Joined
Jun 17, 2011
Messages
15
folks,
not quite sure how to present this properly. so bear with with me:
1. i have userform, and would like to do a calc inside the userform, referencing a cell in the xls
2. the cell is in the same row as the 'active cell', but it is in a different column
and also,
3. since the xls is in development, i keep moving columns around; so i would like to use a reference to the name of the column in the header row, rather than a column letter [like col A, or B, or whatever]

now, this item in the userform gets me the active row: ActiveCell.Row and this gets me the column: "H"
so to get the value in the cell: Me.abc.Value = Range("L" & ActiveCell.Row).Value

what i need to is to replace "L" with a header row 'name' so if i move columns this link still works. i tried this:
Me.txtABC.Value = Range("Table134235[[#Headers],[Sales]]" & ActiveCell.Row).Value and i get this error:
..run time error 1004.. ..Method 'Range' of object '_Global' failed
so the reference to the header row and column: Sales is not returning the equivalent of the old "L"

can anyone tell me what i am missing here?
probably my lack of understanding of what is 'inside' the reference Table134235[[#Headers],[Sales]]. it clearly isn't equal to L.
i tried putting the reference into a MsgBox to display, but that failed as well.

thanks,
ron
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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