ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple VByesno Message boxes no working (https://www.excelbanter.com/excel-programming/439394-multiple-vbyesno-message-boxes-no-working.html)

munchkin

Multiple VByesno Message boxes no working
 
When my 1st message box appears & user click "yes" macro does what it
supposed to do. If user clicks "no", I want another message box to appear
with a "yes/no" option, but I can't figure out how to get the second message
box to appear correctly. I don't know what I'm doing wrong & appreciate any
help!

Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to add another employee?"
Style = vbYesNo
Title = "DAC Sheet Updated"
Response = MsgBox(Msg, Style, Title, Help, Ctxt)

If Response = vbYes Then
Sheets("Sheet1").Select
Range("E4").Select


Else
MyString = "No"
Msg , Style, Title, Help, Ctxt, Response, MyString
Msg = "Are you done?"
Style = vbYesNo
Title = "DAC Sheet Updated"
If Response = vbYes Then
Cells.Select
Selection.Copy
MsgBox ("New info is copied in the clipboard.")
Else: Sheets("Sheet1").Select
End If



Ryan H

Multiple VByesno Message boxes no working
 
Try this. I think this is what you were wanting. I took the liberty of
shortening some of the code as well. Hope this helps! If so, let me know,
click "YES" below.


Dim Msg As String
Dim Style As String
Dim Title As String

Msg = "Do you want to add another employee?"
Style = vbYesNo
Title = "DAC Sheet Updated"

If MsgBox(Msg, Style, Title) = vbYes Then
Sheets("Sheet1").Range("E4").Select
Else
Msg = "Are you done?"

If MsgBox(Msg, Style, Title) = vbYes Then
Cells.Copy
MsgBox ("New info is copied in the clipboard.")
Else
Sheets("Sheet1").Select
End If
End If
--
Cheers,
Ryan


"Munchkin" wrote:

When my 1st message box appears & user click "yes" macro does what it
supposed to do. If user clicks "no", I want another message box to appear
with a "yes/no" option, but I can't figure out how to get the second message
box to appear correctly. I don't know what I'm doing wrong & appreciate any
help!

Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to add another employee?"
Style = vbYesNo
Title = "DAC Sheet Updated"
Response = MsgBox(Msg, Style, Title, Help, Ctxt)

If Response = vbYes Then
Sheets("Sheet1").Select
Range("E4").Select


Else
MyString = "No"
Msg , Style, Title, Help, Ctxt, Response, MyString
Msg = "Are you done?"
Style = vbYesNo
Title = "DAC Sheet Updated"
If Response = vbYes Then
Cells.Select
Selection.Copy
MsgBox ("New info is copied in the clipboard.")
Else: Sheets("Sheet1").Select
End If



munchkin

Multiple VByesno Message boxes no working
 
Thanks - it works!

"Ryan H" wrote:

Try this. I think this is what you were wanting. I took the liberty of
shortening some of the code as well. Hope this helps! If so, let me know,
click "YES" below.


Dim Msg As String
Dim Style As String
Dim Title As String

Msg = "Do you want to add another employee?"
Style = vbYesNo
Title = "DAC Sheet Updated"

If MsgBox(Msg, Style, Title) = vbYes Then
Sheets("Sheet1").Range("E4").Select
Else
Msg = "Are you done?"

If MsgBox(Msg, Style, Title) = vbYes Then
Cells.Copy
MsgBox ("New info is copied in the clipboard.")
Else
Sheets("Sheet1").Select
End If
End If
--
Cheers,
Ryan


"Munchkin" wrote:

When my 1st message box appears & user click "yes" macro does what it
supposed to do. If user clicks "no", I want another message box to appear
with a "yes/no" option, but I can't figure out how to get the second message
box to appear correctly. I don't know what I'm doing wrong & appreciate any
help!

Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to add another employee?"
Style = vbYesNo
Title = "DAC Sheet Updated"
Response = MsgBox(Msg, Style, Title, Help, Ctxt)

If Response = vbYes Then
Sheets("Sheet1").Select
Range("E4").Select


Else
MyString = "No"
Msg , Style, Title, Help, Ctxt, Response, MyString
Msg = "Are you done?"
Style = vbYesNo
Title = "DAC Sheet Updated"
If Response = vbYes Then
Cells.Select
Selection.Copy
MsgBox ("New info is copied in the clipboard.")
Else: Sheets("Sheet1").Select
End If




All times are GMT +1. The time now is 09:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com