bobsburgers
Board Regular
- Joined
- Jun 25, 2017
- Messages
- 60
Hi, all -
Would it be possible to turn to below code into a Macro that repeats its core function until told to stop?
Ideally, it would be run with an "On/Off" button; wherein, while the Macro is "On", the function resets every time it is performed, until the user turns the macro "Off".
Thank you!
Best,
Bob
Would it be possible to turn to below code into a Macro that repeats its core function until told to stop?
Code:
Sub Item_Return()
Dim scanstring As String
Dim foundscan As Range
Dim ws As Worksheet
Dim foundscan_address As String
Set ws = ActiveSheet
scanstring = InputBox("Please enter a value to search for", "Enter value")
With ws.Columns("D")
Set foundscan = .Find(What:=scanstring, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not foundscan Is Nothing Then
foundscan_address = foundscan.Address
Do
foundscan.Offset(0, 4).Value = scanstring
ws.Activate
foundscan.Activate
ActiveWindow.ScrollRow = foundscan.Row
Set foundscan = .FindNext(foundscan)
Loop While Not foundscan Is Nothing And foundscan.Address <> foundscan_address
Else
MsgBox scanstring & " was not found"
End If
End With
End Sub
Ideally, it would be run with an "On/Off" button; wherein, while the Macro is "On", the function resets every time it is performed, until the user turns the macro "Off".
Thank you!
Best,
Bob