Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I capture a date? | Excel Discussion (Misc queries) | |||
Excel screen capture to capture cells and row and column headings | Excel Discussion (Misc queries) | |||
Median of Even Set; How to Capture them? | Excel Discussion (Misc queries) | |||
Up Capture | Excel Programming | |||
Time Capture... | Excel Programming |