ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,227
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I have the code in use shown below.

Can you advise what ive missed please as when i select No the code still runs as opposed to exit.
Yes should continut but No should exit

Code:
Private Sub CommandButton1_Click()MsgBox "Did You Select The Vehicle?", vbYesNo + vbInformation, "Vehicle Selection Checker"
If vbYes Then


Sheets("Sheet1").Range("P6:U6").Copy Sheets("Sheet1").Range("E6")
Sheets("Sheet1").Range("P7").Copy Sheets("Sheet1").Range("E7")


Sheets("Sheet1").Range("E6:J6").Copy Sheets("DR SITE").Range("E6")
Sheets("Sheet1").Range("E7").Copy Sheets("DR SITE").Range("E7")


Sheets("Sheet1").Range("E6:J6").Copy Sheets("EBAY").Range("E6")
Sheets("Sheet1").Range("E7").Copy Sheets("EBAY").Range("E7")


Sheets("DR SITE").Range("E7").Font.Color = vbWhite
Sheets("DR SITE").Range("E7").Borders.LineStyle = xlNone




Sheets("EBAY").Range("E7").Font.Color = vbWhite
Sheets("EBAY").Range("E7").Borders.LineStyle = xlNone




Sheets("DR SITE").Activate
ActiveSheet.Range("E7").Select


Sheets("EBAY").Activate
ActiveSheet.Range("E7").Select


Sheets("Sheet1").Activate
ActiveSheet.Range("P6").Select


ActiveWorkbook.Save
End If


End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
You have to assign the output from the MessageBox to a variable and then test that variable against the vbYes constant. So, instead of this...
Code:
[table="width: 500"]
[tr]
	[td]MsgBox "Did You Select The Vehicle?", vbYesNo + vbInformation, "Vehicle Selection Checker"
If vbYes Then[/td]
[/tr]
[/table]
use something like this...
Code:
[table="width: 500"]
[tr]
	[td]Dim Answer As Long
Answer = MsgBox("Did You Select The Vehicle?", vbYesNo + vbInformation, "Vehicle Selection Checker")
If Answer = vbYes Then[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,456
Messages
6,124,939
Members
449,197
Latest member
k_bs

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