Hi,
I am trying to find start and end of a text in column A,
The text I am searching is WERW
The data in column A is: (in this ex. A2:A5)
WEBBTV
WERW
WERWER
WERWER
Its not working.
batStartRow giv result row 3
batEndRow giv result row 5
Both start and end should be row 3
How to solve this?
I am trying to find start and end of a text in column A,
The text I am searching is WERW
The data in column A is: (in this ex. A2:A5)
WEBBTV
WERW
WERWER
WERWER
Its not working.
batStartRow giv result row 3
batEndRow giv result row 5
Both start and end should be row 3
How to solve this?
Rich (BB code):
Sub Findmytext()
Dim batStartRow As Long
Dim batEndRow As Long
Dim mytext As String
mytext = UserForm16.ListBox1.Value ' in this ex. the value of selected item is WERW
'ListBox1 has single row
With Sheets("Sheet2")
batStartRow = .Range("A:A").Find(What:=mytext, After:=.Range("A1")).Row ' find first match
batEndRow = .Range("A:A").Find(What:=mytext, After:=.Range("A1"), SearchDirection:=xlPrevious).Row ' fiknd last match
End With
End Sub