Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Finding the cell with a specified string

I am importing worksheets into a workbook which then need to parse. I then
need to find the cell on a different worksheet which has the string
"value_GuaranteedCashvalue". I don't know what column or row it will end up
in upon import.

If I know the column, I can find the row by using the Match function. What I
can't seem to get is finding the number of the column.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Finding the cell with a specified string

On Mon, 30 Mar 2009 03:50:06 -0700, Don Kline
wrote:

I am importing worksheets into a workbook which then need to parse. I then
need to find the cell on a different worksheet which has the string
"value_GuaranteedCashvalue". I don't know what column or row it will end up
in upon import.

If I know the column, I can find the row by using the Match function. What I
can't seem to get is finding the number of the column.



I'm not sure exactly what you mean by "find the cell".

But here is a simple user defined function (UDF) that will return the address
(including the sheet name) of the first cell that contains that String.

You may want to modify the parameters somewhat. I assumed that you wanted a
*case-sensitive search* where the cell contained *ONLY* the searchString. You
can easily change that in the UDF.

The function will return a #VALUE! error if the search string is not present on
the designated worksheet.

To enter this User Defined Function (UDF), <alt-F11 opens the Visual Basic
Editor.

Ensure your project is highlighted in the Project Explorer window.

Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.

To use this User Defined Function (UDF), enter a formula like

=StringAddress(FindString, SheetToSearch )

in some cell. FindString and SheetToSearch can be either literal strings or
cell referencs containing the string.

e.g. =StringAddress(C1, "Sheet2")

==============================================
Option Explicit
Function StringAddress(FindString As String, SheetToSearch As String) As String
Dim ws As Worksheet
Set ws = Worksheets(SheetToSearch)
With ws
StringAddress = ws.Name & "!" & .Cells.Find(What:=FindString, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=True).Address
End With
End Function
====================================



--ron
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Finding the cell with a specified string

Thanks for your help. I am good to go.

BTW - would there be a way to do this using column numbers rather then
letters. Again - it is working for me in its current form.

"Ron Rosenfeld" wrote:

On Mon, 30 Mar 2009 03:50:06 -0700, Don Kline
wrote:

I am importing worksheets into a workbook which then need to parse. I then
need to find the cell on a different worksheet which has the string
"value_GuaranteedCashvalue". I don't know what column or row it will end up
in upon import.

If I know the column, I can find the row by using the Match function. What I
can't seem to get is finding the number of the column.



I'm not sure exactly what you mean by "find the cell".

But here is a simple user defined function (UDF) that will return the address
(including the sheet name) of the first cell that contains that String.

You may want to modify the parameters somewhat. I assumed that you wanted a
*case-sensitive search* where the cell contained *ONLY* the searchString. You
can easily change that in the UDF.

The function will return a #VALUE! error if the search string is not present on
the designated worksheet.

To enter this User Defined Function (UDF), <alt-F11 opens the Visual Basic
Editor.

Ensure your project is highlighted in the Project Explorer window.

Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.

To use this User Defined Function (UDF), enter a formula like

=StringAddress(FindString, SheetToSearch )

in some cell. FindString and SheetToSearch can be either literal strings or
cell referencs containing the string.

e.g. =StringAddress(C1, "Sheet2")

==============================================
Option Explicit
Function StringAddress(FindString As String, SheetToSearch As String) As String
Dim ws As Worksheet
Set ws = Worksheets(SheetToSearch)
With ws
StringAddress = ws.Name & "!" & .Cells.Find(What:=FindString, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=True).Address
End With
End Function
====================================



--ron

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Finding the cell with a specified string

On Mon, 30 Mar 2009 09:21:03 -0700, Don Kline
wrote:

Thanks for your help. I am good to go.


You're welcome. Glad to help.

BTW - would there be a way to do this using column numbers rather then
letters.


I'm sure there is. However, since I don't know what you mean, I can envision
multiple possibilities. How about you give some specific examples of input to
and output from this function.
--ron
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Finding the cell with a specified string

On Mon, 30 Mar 2009 09:21:03 -0700, Don Kline
wrote:

Thanks for your help. I am good to go.

BTW - would there be a way to do this using column numbers rather then
letters. Again - it is working for me in its current form.



Another solution -- this time an **array** formula:

=ADDRESS(MAX((rng=C1)*ROW(rng)),MAX((rng=C1)*COLUM N(rng)))

where

rng refers to the range to search (e.g. Sheet2!A1:Z10000)
*Note that in versions of Excel prior to 2007, the row number cannot
be the very last row on the worksheet.
C1 is the String being searched for.


To enter an *array* formula, after entering
the formula into the cell or formula bar, hold down
<ctrl<shift while hitting <enter. If you did this
correctly, Excel will place braces {...} around the formula.
--ron


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
Finding 1 of 3 different strings in a string MarkMcG Excel Worksheet Functions 3 June 10th 08 05:55 PM
Finding the last cell to enter a string and/or a sum formula rojobrown Excel Worksheet Functions 5 October 3rd 06 09:36 PM
finding a name in a string jay d Excel Worksheet Functions 1 June 12th 06 09:25 PM
Finding a text string w/in a Cell ricxl Excel Discussion (Misc queries) 12 March 20th 06 03:47 AM
finding what numbers are in a string (Day 2) David Excel Worksheet Functions 0 May 26th 05 10:10 PM


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