Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Column Names/Label??

Status
Not open for further replies.

LJA520

Programmer
Nov 3, 2003
65
US
Hello!

I have an excel spreadsheet that has the account names in the columns and the account information in the rows. I have labeled/named each column with the corresponding account number. I'm trying to write a macro that will update a field depending on the account number label. Is there a way in vba to get the column name. I'm aware that you can set the name of a range, but do you know how to pull the name of a range?? Any ideas?

Thanks so much for your help in advance!!!
LJA520
 
LJA520,

It might be helpful to post a small representative sample of your data.

You could use Insert/Name/Create - Create names in Top Row to create the range names. Macro record and modify as needed.

Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
This is a sample spreadsheet:

A B C D
Fund Name1 Fund Name2 Fund Name3
Assets 31,351.00 51,561.00 32,135.00
Liabilities 25,165.00 616,133.00 321,323.00


Shares Outstanding ? ? ?


The name for column B is AcctNum1, C is AcctNum2....

Then at the bottom to fill the "shares outstanding", we are going to reference another worksheet in the current workbook for that current account number (which is the column name).

I'd like to automate this by referencing the column name to get the account number.

IS there a function for that?


Thank you!!!

 
A starting point for column B:
MsgBox Range("$B:$B").Name.Name

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PH,

That's exactly what I was looking for.

Thank you!
LJA
 
Is there a way to automatically begin running a macro when the workbook is opened?
 
Take a look at the Workbook_Open event procedure.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you, One last question.

Is there a way to set a cell equal to the column name without writing any code. Is there a function that does something like "this cell is equal to the current column's name"?

Thank you!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top