MsgBox default option

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I have the code as shown below.
Currently when the MsgBox opens & i see "CONTINUE TO OPEN POSTAGE FORM", vbInformation + vbYesNo + vbDefaultButton2, "OVERIDE POSTAGE USERFORM")"
The NO button is selected as default.

How can i make the YES the default button.

Thanks

Rich (BB code):
Private Sub Worksheet_Activate()
Application.Goto Sheets("POSTAGE").Range("A" & Rows.Count).End(xlUp).Offset(0, 0), True
ActiveWindow.SmallScroll UP:=15

Dim answer As Integer
    answer = MsgBox("DO YOU WISH TO OPEN THE POSTAGE FORM", vbQuestion + vbYesNo + vbDefaultButton2, "POSTAGE OPEN USERFORM MESSAGE")
    If answer = vbNo Then
      Exit Sub
    Else
        Dim ws As Worksheet, lRow As Long, i As Long
        Set ws = Application.Worksheets("POSTAGE")
        lRow = ws.Cells(Rows.Count, 1).End(xlUp).Row ' count total rows using A col
        For i = 8 To lRow ' <-- change number rows to check here
            If ws.Range("G" & i).Value = "POSTED" Then
                PostageTransferSheet.Show
                Exit Sub
            End If
        Next i
        MsgBox "NO NAMES TO SHOW AS ALL PARCELS HAVE NOW BEEN DELIVERED", vbInformation, "POSTAGE DATE TRANSFER SHEET MESSAGE"
        answer = MsgBox("CONTINUE TO OPEN POSTAGE FORM", vbInformation + vbYesNo + vbDefaultButton2, "OVERIDE POSTAGE USERFORM")
        If answer = vbYes Then
        PostageTransferSheet.Show
        Else
        Exit Sub
        End If
        End If

End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Just change the 2 to a 1
VBA Code:
answer = MsgBox("CONTINUE TO OPEN POSTAGE FORM", vbInformation + vbYesNo + vbDefaultButton1, "OVERIDE POSTAGE USERFORM")
 
Upvote 0

Forum statistics

Threads
1,214,881
Messages
6,122,074
Members
449,064
Latest member
MattDRT

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