LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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



 
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 04:57 PM.

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

About Us

"It's about Microsoft Excel"