Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Problem with Msgbox Code

I have the following code in a project which is responding in a way I
don't understand. Any enlightenment would be appreciated as I am new at
this. When the Cancel button is clicked I get an error code.

Else
MsgBox " There were no files found. ", vbRetryCancel, "Please
Respond"
If Msg = 4 Then
' What to do code
End If
If Msg = 7 Then
Exit Sub
End If

Run-time error '380':
Could not set the List property. Invalid property value.

All I am trying to do is to give the user a opportunity to exit the
procedure.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Problem with Msgbox Code

Hi Old Dog,

Try this slight adaptation of your code:

'==========
Sub aTester()
Dim Msg As Long
Msg = MsgBox(" There were no files found. ", _
vbRetryCancel, "Please Respond")
If Msg = 4 Then
'User pressed Retry: What to do code
End If
If Msg = 2 Then
MsgBox "You cancelled!"
Exit Sub
End If

End Sub
'<<==========

---
Regards,
Norman



"Old Dog" wrote in message
oups.com...
I have the following code in a project which is responding in a way I
don't understand. Any enlightenment would be appreciated as I am new at
this. When the Cancel button is clicked I get an error code.

Else
MsgBox " There were no files found. ", vbRetryCancel, "Please
Respond"
If Msg = 4 Then
' What to do code
End If
If Msg = 7 Then
Exit Sub
End If

Run-time error '380':
Could not set the List property. Invalid property value.

All I am trying to do is to give the user a opportunity to exit the
procedure.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Problem with Msgbox Code

Or, rather:

Sub aTester()
Dim Msg As Long

Msg = MsgBox(" There were no files found. ", _
vbRetryCancel, "Please Respond")

If Msg = 4 Then
'User pressed Retry: What to do code
ElseIf Msg = 2 Then
MsgBox "You cancelled!"
Exit Sub
End If

End Sub

---
Regards,
Norman


"Norman Jones" wrote in message
...
Hi Old Dog,

Try this slight adaptation of your code:

'==========
Sub aTester()
Dim Msg As Long
Msg = MsgBox(" There were no files found. ", _
vbRetryCancel, "Please Respond")
If Msg = 4 Then
'User pressed Retry: What to do code
End If
If Msg = 2 Then
MsgBox "You cancelled!"
Exit Sub
End If

End Sub
'<<==========

---
Regards,
Norman



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Problem with Msgbox Code

One followup question:

Once, I Exit this routine which is behind a Userform, the code returns
to the original sub routine with the Userform still on the screen. Is
there away to avoid this and get the last line End Sub to run.

The originating routine has the following code:

Sub FileSearchTest()

FilesSelect1UserForm.Show

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
Msgbox Code Help Please.... kmwhitt Excel Discussion (Misc queries) 5 September 21st 06 01:52 AM
VBA code using if then and msgbox snoopy Excel Discussion (Misc queries) 0 December 1st 05 08:48 PM
syntax for code in MsgBox()? Ouka[_4_] Excel Programming 2 July 20th 05 05:18 PM
MsgBox Code Error MBlake Excel Programming 8 May 2nd 05 11:16 PM


All times are GMT +1. The time now is 04:03 AM.

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

About Us

"It's about Microsoft Excel"