Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to return a column number?

I have a large database that continues to grow on a weekly basis. Within
this database, I have formula references using vlookup, but I keep having to
adjust the col_index_num for these cells because the database keeps
expanding. Is there a function I can use to specify the right-most column in
the database instead of using a fixed column for vlookup? Ie,
"farthest-right" instead of "M", so if the database extends through columns
AK or LAA or beyond it always returns the column label of that right-most
data column?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default How to return a column number?

Hi

You could use a COUNTA function on a row in the database that has no empty
cells (header row for instance).

That count gives you the number of columns used if you start from column 1.


--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


"sycsummit" wrote:

I have a large database that continues to grow on a weekly basis. Within
this database, I have formula references using vlookup, but I keep having to
adjust the col_index_num for these cells because the database keeps
expanding. Is there a function I can use to specify the right-most column in
the database instead of using a fixed column for vlookup? Ie,
"farthest-right" instead of "M", so if the database extends through columns
AK or LAA or beyond it always returns the column label of that right-most
data column?

  #3   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default How to return a column number?

One way, check the column reference given by:

Dim lCol as long
lCol = ActiveSheet.UsedRange.Columns.Count
Msgbox lCol

You may need to subtract one from the value returned depending on how
VLookup counts, I can't remember whether it starts at zero or one...then use
the variable lCol in your VLookup.


Hope this helps.

"sycsummit" wrote:

I have a large database that continues to grow on a weekly basis. Within
this database, I have formula references using vlookup, but I keep having to
adjust the col_index_num for these cells because the database keeps
expanding. Is there a function I can use to specify the right-most column in
the database instead of using a fixed column for vlookup? Ie,
"farthest-right" instead of "M", so if the database extends through columns
AK or LAA or beyond it always returns the column label of that right-most
data column?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to return a column number?

Awesome. Counta worked. Thanks for the tip!

"Wigi" wrote:

Hi

You could use a COUNTA function on a row in the database that has no empty
cells (header row for instance).

That count gives you the number of columns used if you start from column 1.


--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


"sycsummit" wrote:

I have a large database that continues to grow on a weekly basis. Within
this database, I have formula references using vlookup, but I keep having to
adjust the col_index_num for these cells because the database keeps
expanding. Is there a function I can use to specify the right-most column in
the database instead of using a fixed column for vlookup? Ie,
"farthest-right" instead of "M", so if the database extends through columns
AK or LAA or beyond it always returns the column label of that right-most
data column?

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
Return column number from column header text Roger[_3_] Excel Discussion (Misc queries) 4 February 14th 08 09:40 PM
How to return column number moonhk Excel Programming 4 November 7th 07 04:10 PM
Look up values in a column and return ALL corresponding row number Ima Nidiot New Users to Excel 2 January 9th 07 02:51 PM
Column() to return a letter instead of a number? cKBoy Excel Worksheet Functions 16 February 17th 06 04:50 AM
Excel - Return column alphabet from column number Sathyaish Excel Programming 2 April 7th 04 02:40 PM


All times are GMT +1. The time now is 01:52 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"