Kemidan2014
Board Regular
- Joined
- Apr 4, 2022
- Messages
- 229
- Office Version
- 365
- Platform
- Windows
I wanted to set up a simple reminder message box at the start of a macro to ask if the user updated a specific file and basically OK iand continue he macro or Stop the macro if they hit cancel
I googled Msgboxs for vbokCancel types but i dont get a real clear examples on how to exectue them just explanations on the options for message boxes
is it really as simple as i just need "MsgBox ("Did you Remember to update ToyotaDefect.xlsx?"), vbOKCancel" ? I feel like theres a requirement to assign what OK button does and the Cancel button does.
I googled Msgboxs for vbokCancel types but i dont get a real clear examples on how to exectue them just explanations on the options for message boxes
is it really as simple as i just need "MsgBox ("Did you Remember to update ToyotaDefect.xlsx?"), vbOKCancel" ? I feel like theres a requirement to assign what OK button does and the Cancel button does.
VBA Code:
Sub Defect()
'Do not run with out toyota defect open
Dim Resp As String
MsgBox ("Did you Remember to update ToyotaDefect.xlsx?"), vbOKCancel
If Resp = vbCancel Then
Exit Sub
Else: Resume Next
End If
Sheets("Complaints").Unprotect Password:="Secret"
Application.ScreenUpdating = False
Workbooks.Open ("O:\1_All Customers\Current Complaints\ToyotaDefect.xlsx")
Dim LastRow As Long, fromsh As Worksheet, tosh As Worksheet, lastrowb As Long
Set fromsh = Workbooks("ToyotaDefect.xlsx").Sheets("Data")
Set tosh = Workbooks("Customer Complaint Tracker.xlsm").Sheets("Complaints")
LastRow = fromsh.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
lastrowb = tosh.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With tosh
.Range("AX2:AX" & lastrowb).Formula = "=SUMIF([ToyotaDefect.xlsx]Data!$A:$A,A2,[ToyotaDefect.xlsx]Data!$AC:$AD)"
.Range("AX2:AX" & lastrowb).SpecialCells(xlCellTypeVisible).Copy
.Range("AI2").PasteSpecial xlPasteValues
End With
Sheets("Complaints").Protect Password:="Secret"
End Sub