Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default How to capture row of a string value

I need to capture the row of a selected text value. Example:

Sheets(1).Range("A1").value = "LM "
"LM" is also located somewhere in column F of Sheet2
I need to lookup LM in column F of sheet2 and capture the row.

How can I do that either as a formula in a cell or vb code?

Glen


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How to capture row of a string value

Hi Glen

Try this example

Sub Find_First()
Dim FindString As String
Dim Rng As Range
FindString = "LM"
Set Rng = Sheets("sheet2").Range("F:F").Find(What:=FindStrin g, _
After:=Range("F" & Rows.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
MsgBox Rng.Row
Else
MsgBox "FindString is Not in the column"
End If
End Sub

Or with a inputbox

Sub Find_First()
Dim FindString As String
Dim Rng As Range
FindString = InputBox("Enter a Search value")
If Trim(FindString) < "" Then
Set Rng = Sheets("sheet2").Range("F:F").Find(What:=FindStrin g, _
After:=Range("F" & Rows.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
MsgBox Rng.Row
Else
MsgBox "FindString is Not in the column"
End If
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Glen Mettler" wrote in message ...
I need to capture the row of a selected text value. Example:

Sheets(1).Range("A1").value = "LM "
"LM" is also located somewhere in column F of Sheet2
I need to lookup LM in column F of sheet2 and capture the row.

How can I do that either as a formula in a cell or vb code?

Glen




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 capture a date? Capture a variable date & use with text Excel Discussion (Misc queries) 3 November 27th 08 02:40 AM
Excel screen capture to capture cells and row and column headings jayray Excel Discussion (Misc queries) 5 November 2nd 07 11:01 PM
Median of Even Set; How to Capture them? Mike Excel Discussion (Misc queries) 7 July 28th 05 01:24 PM
Up Capture Alex Excel Programming 0 July 26th 04 08:09 PM
Time Capture... Gordon Cartwright Excel Programming 0 November 18th 03 08:50 PM


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