Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How do I refer (in VBA Code) to a column by caption instead of index ?

Thanks a lot...

Alex. Nitulescu

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default How do I refer (in VBA Code) to a column by caption instead of index ?

Do you mean:
Columns("G").Select
OR:
Columns("G:G").Select

Instead of:
Columns(7).Select

Or something else?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How do I refer (in VBA Code) to a column by caption instead of index ?

No, I was referring to something like

Columns("My wonderful new caption") instead of Columns(4), or
Columns("G")...

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I refer (in VBA Code) to a column by caption instead of index ?


Hello Radu,

Put your caption in Row 1. Select the Column by clicking the column
letter. Click *Insert* on the menu bar and select *Name*. Check that
the entire column is selected. Look at the *Refers to:* box. If you
selected column "G" on sheet 1 you will see "=Sheet1!$G:$G". The double
column letter indicates the entire column is selected.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=492248

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How do I refer (in VBA Code) to a column by caption instead of index ?

Thank you, Ross.... What I need is this:

In a module (VBA code) I need to be able to refer to columns in my
spreadsheet not by position, since the user might change the columns'
order, but by Caption (the caption is NOT negociable).

So in the first row I have the captions, like
Caption 1 Caption 2 Caption 3
and in the subsequent rows I have the data:
a b c
d e f

I need to be able to write in code NOT .Columns(2), NOT columns ("B"),
since the columns might move, but .Columns("Caption 2")...

Radu



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default How do I refer (in VBA Code) to a column by caption instead of index ?

Record a macro while doing this:
Select your columns
InsertNameCreate
check Top row

Include this in your code

Now you can refer to the columns:

..Range("Caption2")


--
Kind regards,

Niek Otten



"Radu" wrote in message
oups.com...
Thank you, Ross.... What I need is this:

In a module (VBA code) I need to be able to refer to columns in my
spreadsheet not by position, since the user might change the columns'
order, but by Caption (the caption is NOT negociable).

So in the first row I have the captions, like
Caption 1 Caption 2 Caption 3
and in the subsequent rows I have the data:
a b c
d e f

I need to be able to write in code NOT .Columns(2), NOT columns ("B"),
since the columns might move, but .Columns("Caption 2")...

Radu



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I refer to other macros inside a macro code? Erkka Excel Programming 3 July 26th 05 03:27 PM
How to refer to a cell format code? A difficult problem Excel Discussion (Misc queries) 1 May 25th 05 08:42 AM
Refer to Worksheet Ranges in Code Andibevan[_2_] Excel Programming 8 March 30th 05 12:20 PM
More then 1 Excel object running at same time , how can I refer to right one in code? Dave Lauberts Excel Programming 5 October 28th 04 03:57 PM
refer to the sheets Name property in my code (not what is on the Tab) Sandy[_5_] Excel Programming 3 January 29th 04 08:45 PM


All times are GMT +1. The time now is 02:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"