Run continuously

dwarek

Board Regular
Joined
Jul 15, 2016
Messages
79
Hello everyone i have simple vba code to find a word in the worksheet but i have a small issue, when i find the word the cursor moves to the word but the small window where i type the text disappears , i want to run the program continuously until i press the cancel button and below is my code, pls help me out Thanks in advance

Sub test2()

Dim x As String
Dim rng As Range
Dim cell As Range


Set rng = Range("D1", Cells(Rows.Count, "D").End(xlUp)).Rows


x = InputBox("Word you want to find?", "Find")


For Each cell In rng.Resize(, 2).Cells


If Not cell.Find(x) Is Nothing Then
cell.Select
Exit Sub

End If


Next


End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hello,

can you pls try this? Hope it will help you and hope I understood well your request :-) If not, let me know...

Code:
Sub test2()

Dim x As String
Dim rng As Range
Dim cell As Range

Set rng = Range("D1", Cells(Rows.Count, "D").End(xlUp)).Rows

x = InputBox("Word you want to find?", "Find")

For Each cell In rng.Resize(, 2).Cells

If Not cell.Find(x) Is Nothing Then
cell.Select

x = InputBox("Word you want to find?", "Find")

End If

If x = vbNullString Then
Exit Sub
End If

Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top