Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Hal Hal is offline
external usenet poster
 
Posts: 36
Default Return Value from MsgBox

If the string from the input box is not found, I want to rerun the code if
the retry button is selected from the message box.

How do I fix the code below to make this work?

Sub FindStr_sub()
Dim s As String, t As String, q As String
Dim r As Range
Dim response As Byte
t = Chr(10) & Chr(10)
s = Application.InputBox("Enter the Word: ", "Locate 'Word'")
DoOver:
For Each r In ActiveSheet.UsedRange
With r
If InStr(1, .Value, s) 0 Then
q = q + .Address & " " & .Value & t
End If
End With
Next
If q < "" Then
MsgBox "Found the Word in Cell(s)" & t & q, , "Word Location"
Else
MsgBox "Did not find the Word " & t & Chr(34) & s & Chr(34),
vbRetryCancel, "Word Location"
If response = vbRetry Then
GoTo DoOver
Else
End If
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Return Value from MsgBox

Dim response as Variable, then make it = to the msgbox:

Sub FindStr_sub()
Dim s As String, t As String, q As String
Dim r As Range
Dim response 'As Byte
t = Chr(10) & Chr(10)
s = Application.InputBox("Enter the Word: ", "Locate 'Word'")
DoOver:
For Each r In ActiveSheet.UsedRange
With r
If InStr(1, .Value, s) 0 Then
q = q + .Address & " " & .Value & t
End If
End With
Next
If q < "" Then
MsgBox "Found the Word in Cell(s)" & t & q, , "Word Location"
Else
response = MsgBox("Did not find the Word " & t & Chr(34) & s & Chr(34), _
vbRetryCancel, "Word Location")
If response = vbRetry Then
GoTo DoOver
Else
End If
End If
End Sub

Mike F
"Hal" wrote in message
...
If the string from the input box is not found, I want to rerun the code if
the retry button is selected from the message box.

How do I fix the code below to make this work?

Sub FindStr_sub()
Dim s As String, t As String, q As String
Dim r As Range
Dim response As Byte
t = Chr(10) & Chr(10)
s = Application.InputBox("Enter the Word: ", "Locate 'Word'")
DoOver:
For Each r In ActiveSheet.UsedRange
With r
If InStr(1, .Value, s) 0 Then
q = q + .Address & " " & .Value & t
End If
End With
Next
If q < "" Then
MsgBox "Found the Word in Cell(s)" & t & q, , "Word Location"
Else
MsgBox "Did not find the Word " & t & Chr(34) & s & Chr(34),
vbRetryCancel, "Word Location"
If response = vbRetry Then
GoTo DoOver
Else
End If
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
Hal Hal is offline
external usenet poster
 
Posts: 36
Default Return Value from MsgBox

Thanks Mike,

That and relocating the DoOver label has it working now.

Originally, I think I tried setting response = msgbox but it did not work
becase I left the ( ) out of the msgbox statment.

Regards,

"Mike Fogleman" wrote:

<snip
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Return Value from MsgBox

download mztools. it has a msgbox builder and a lot of other things

http://www.mztools.com/v3/mztools3.aspx

--


Gary


"Hal" wrote in message
...
If the string from the input box is not found, I want to rerun the code if
the retry button is selected from the message box.

How do I fix the code below to make this work?

Sub FindStr_sub()
Dim s As String, t As String, q As String
Dim r As Range
Dim response As Byte
t = Chr(10) & Chr(10)
s = Application.InputBox("Enter the Word: ", "Locate 'Word'")
DoOver:
For Each r In ActiveSheet.UsedRange
With r
If InStr(1, .Value, s) 0 Then
q = q + .Address & " " & .Value & t
End If
End With
Next
If q < "" Then
MsgBox "Found the Word in Cell(s)" & t & q, , "Word Location"
Else
MsgBox "Did not find the Word " & t & Chr(34) & s & Chr(34),
vbRetryCancel, "Word Location"
If response = vbRetry Then
GoTo DoOver
Else
End If
End If
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveX Control Return Keypress MsgBox Loop tomgreen1000 Excel Programming 3 August 3rd 07 10:30 PM
Return Address of Blank Cells in MsgBox Sandy Excel Programming 4 August 25th 05 02:06 PM
How to put a 'return' in Msgbox? HausMaus Excel Programming 3 August 10th 04 08:21 PM
Msgbox text hard return Jo[_6_] Excel Programming 2 August 5th 04 12:01 AM
MsgBox carriage return Art Excel Programming 2 October 21st 03 03:31 PM


All times are GMT +1. The time now is 02:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"