I have a subroutine that searches for an occurrence of a string in another workbook. I’m trying to get an error message to pop up if the string can’t be found (it’s most likely due to spelling mistakes), as vbModeless, and allows to user to click on the cell in the searched sheet with the correct value. Then I’d like to resume the search with the new value.
I’m at the moment stuck on making my simple MsgBox to be modeless. Can anyone help? So far I have (simplified):
With ... On Error GoTo UserSelect celladdress = .Range('a1:bb100').Find('searchstring').Address
And my error label:
UserSelect: MsgBox('Select the cell with the correct spelling') vbModeless newstring = ActiveCell.Value searchstring = newstring Resume
I think it’s the Modeless MsgBox giving me grief.
I don’t believe that you can use vbModeless with msgbox. That is for use with the Show method of a user form.
What you probably need to do is create a user form that has a refedit control and a button on it. They can then pick a cell with the refedit control. When the user clicks on the button set a public variable on the form with the cell reference the selected.
Then you you need to use ‘.Show vbModal’ on the user form and read off the cell they selected from the form public variable.
Edit:
Actually, you shouldn’t need the public variable as the refedit control should be a public property of the form anyway.