Message box

goldcat

Board Regular
Joined
Jun 26, 2002
Messages
160
I have to following code to copy date from one sheet to another and to pop up a message box to ask a question of the user ... the box doesn't appear.


help please :oops:

Application.ScreenUpdating = False

Sheets("Paid Outs").Select
Rows("6:26").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown
Range("A6").Select
Sheets("Daily Reconciliation Sheet").Select
Range("G29:I48").Select
Selection.Copy
Sheets("Paid Outs").Select
Range("A6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Rows("45:86").Select
Range("B45").Activate
Selection.Delete Shift:=xlUp

Range("A6:k105").Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A6"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Application.ScreenUpdating = True

Dim Msg, Style, Title, Response, MyString
Msg = "Do you want to Update Paidouts ?" ' Define message.
Style = vbYesNo + vbDefaultButton2 ' Define buttons.
Title = "Paidout Update" ' Define title.


If Response = vbYes Then ' User chose Yes.
MyString = Sheets("Paid Outs").Select
Range("A6").Select ' Activate the Paid out Sheet to work on.

Else ' User chose No.
MyString = Sheets("Daily Reconciliation Sheet").Select
Range("C4").Select ' Go back to the Imput Sheet.
End If

End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
goldcat said:
I have to following code to copy date from one sheet to another and to pop up a message box to ask a question of the user ... the box doesn't appear.


help please :oops:

Application.ScreenUpdating = False

Sheets("Paid Outs").Select
Rows("6:26").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown
Range("A6").Select
Sheets("Daily Reconciliation Sheet").Select
Range("G29:I48").Select
Selection.Copy
Sheets("Paid Outs").Select
Range("A6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Rows("45:86").Select
Range("B45").Activate
Selection.Delete Shift:=xlUp

Range("A6:k105").Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A6"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Application.ScreenUpdating = True

Dim Msg, Style, Title, Response, MyString
Msg = "Do you want to Update Paidouts ?" ' Define message.
Style = vbYesNo + vbDefaultButton2 ' Define buttons.
Title = "Paidout Update" ' Define title.


'Add This...
Response =MsgBox(Msg,Style,Title)


If Response = vbYes Then ' User chose Yes.
MyString = Sheets("Paid Outs").Select
Range("A6").Select ' Activate the Paid out Sheet to work on.

Else ' User chose No.
MyString = Sheets("Daily Reconciliation Sheet").Select
Range("C4").Select ' Go back to the Imput Sheet.
End If

End Sub
 
Upvote 0
Hi g,

You haven't defined what Response should be.

Like this:
Code:
Sub test()
Dim Msg As String, Style As Integer, Title As String, Response As Integer

Msg = "Do you want to Update Paidouts ?" ' Define message.
Style = vbYesNo + vbDefaultButton2 ' Define buttons.
Title = "Paidout Update" ' Define title.

Response = MsgBox(prompt:=Msg, Buttons:=Style, Title:=Title)

If Response = vbYes Then ' User chose Yes.
Else ' User chose No.
End If

End Sub
HTH


Edit: Doh. Too slow :)
 
Upvote 0
And why couldn't I see that (bangs head very hard on desk). maybe I should just go to bed !!!.

g
 
Upvote 0
Richie(UK) said:
Hi g,

You haven't defined what Response should be.

Like this:
Code:
Sub test()
Dim Msg As String, Style As Integer, Title As String, Response As Integer

Msg = "Do you want to Update Paidouts ?" ' Define message.
Style = vbYesNo + vbDefaultButton2 ' Define buttons.
Title = "Paidout Update" ' Define title.

Response = MsgBox(prompt:=Msg, Buttons:=Style, Title:=Title)

If Response = vbYes Then ' User chose Yes.
Else ' User chose No.
End If

End Sub
HTH

I must be really blonde tonite as I added the code you provided but I now get a compile error at the hilited point and I cannot see what the problem is the sheet spelling is correct

If Response = vbYes Then ' User chose Yes.
MyString = Sheets("Paid Outs").Select
Range("A6").Select ' Activate the Paid out Sheet to work on.

Else ' User chose No.
MyString = Sheets("Daily Reconciliation Sheet").Select
Range("C4").Select ' Go back to the Imput Sheet.
End If
 
Upvote 0
Same problem as previously. You have not defined “MyString” (at least it is not obvious from your code snippet that you have defined “MyString”) - just delete the reference i.e.

Change:
MyString = Sheets("Paid Outs").Select

To:
Sheets("Paid Outs").Select

Ditto for the following line that selects the "Daily Reconciliation Sheet” worksheet.

You could shorten your code a bit with the following:

If Response = vbYes Then ' User chose Yes.
Application.Goto Reference:=Worksheets("Paid Outs").Range("A6")

Else ' User chose No.
Application.Goto Reference:=Sheets("Daily Reconciliation Sheet").Range("C4")

End if


Regards,

Mike
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,164
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top