Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to return the row number or column letter as a variable?

Hi,

I have a sheet with measurement data.
The first row contains the headers waith the parameter name.
I have to look to a specific data from one parameter and find the data from
another parameter in the same row.
Unfortunately the order of the parameters is not always the same.

I want to solve this by searching for the first parameter (stapp) and set a
variable (col_stapp) equal to the letter of the column of that parameter.
I tried the following code:
Dim col_stapp as String
Cells.find(What:="stapp", After:=ActiveCell, LookIn:=xlValue,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearcgDirection:=xlNext,
MatchCase:=False).Activate
col_stapp = Cells.Column

But I always get for col_stapp the value 1.

Whats wrong and how can I solve this?

Thanks for your help,

Gerrit


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default How to return the row number or column letter as a variable?

have not tryed your code but try
col_stapp = activeCell.Column
instead of
col_stapp = Cells.Column
in the last line of your code


"cells" referes to all cells in the work sheet so that is
why its returning 1

-----Original Message-----
Hi,

I have a sheet with measurement data.
The first row contains the headers waith the parameter

name.
I have to look to a specific data from one parameter and

find the data from
another parameter in the same row.
Unfortunately the order of the parameters is not always

the same.

I want to solve this by searching for the first

parameter (stapp) and set a
variable (col_stapp) equal to the letter of the column

of that parameter.
I tried the following code:
Dim col_stapp as String
Cells.find(What:="stapp", After:=ActiveCell,

LookIn:=xlValue,
LookAt:=xlWhole, SearchOrder:=xlByRows,

SearcgDirection:=xlNext,
MatchCase:=False).Activate
col_stapp = Cells.Column

But I always get for col_stapp the value 1.

Whats wrong and how can I solve this?

Thanks for your help,

Gerrit


.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to return the row number or column letter as a variable?

Dim col_stapp as String
Cells.find(What:="stapp", After:=ActiveCell, LookIn:=xlValue,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearcgDirection:=xlNext,
MatchCase:=False).Activate
col_stapp = ActiveCell.Column


--
Regards,
Tom Ogilvy

"Gerrit van Stempvoort" wrote in message
...
Hi,

I have a sheet with measurement data.
The first row contains the headers waith the parameter name.
I have to look to a specific data from one parameter and find the data

from
another parameter in the same row.
Unfortunately the order of the parameters is not always the same.

I want to solve this by searching for the first parameter (stapp) and set

a
variable (col_stapp) equal to the letter of the column of that parameter.
I tried the following code:
Dim col_stapp as String
Cells.find(What:="stapp", After:=ActiveCell, LookIn:=xlValue,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearcgDirection:=xlNext,
MatchCase:=False).Activate
col_stapp = Cells.Column

But I always get for col_stapp the value 1.

Whats wrong and how can I solve this?

Thanks for your help,

Gerrit




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default How to return the row number or column letter as a variable?

There's no need to activate the cell before assigning to the variable:

Dim col_stapp As String
col_stapp = Cells.Find(What:="stapp", After:=ActiveCell, _
LookIn:=xlValue, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Column

Alan Beban

Tom Ogilvy wrote:
Dim col_stapp as String
Cells.find(What:="stapp", After:=ActiveCell, LookIn:=xlValue,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearcgDirection:=xlNext,
MatchCase:=False).Activate
col_stapp = ActiveCell.Column


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to return the row number or column letter as a variable?

Hi Guy's

Thanks for your help.
Alan, your right, it is not needed to activate the cell before assigning to
the variable, but because I had to search in that column for a specific
value is is easier to activate the cell. So I will use the solution from
Tom.

Gerrit van Stempvoort

"Alan Beban" wrote in message
...
There's no need to activate the cell before assigning to the variable:

Dim col_stapp As String
col_stapp = Cells.Find(What:="stapp", After:=ActiveCell, _
LookIn:=xlValue, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Column

Alan Beban

Tom Ogilvy wrote:
Dim col_stapp as String
Cells.find(What:="stapp", After:=ActiveCell, LookIn:=xlValue,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearcgDirection:=xlNext,
MatchCase:=False).Activate
col_stapp = ActiveCell.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
Function that will look at letter in a column and return a number locasciok1 Excel Worksheet Functions 4 November 11th 09 06:31 AM
Column() to return a letter instead of a number? cKBoy Excel Worksheet Functions 16 February 17th 06 04:50 AM
column header changed from letter to number, how return to letter Ron Excel Discussion (Misc queries) 2 May 9th 05 08:34 PM
Auto number w/ different letter-number combos in same column Colleen B Excel Worksheet Functions 2 February 23rd 05 02:41 PM
value of a cell based upon column letter and variable for row# Tod[_2_] Excel Programming 1 August 17th 03 08:28 PM


All times are GMT +1. The time now is 01:36 AM.

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"