ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   "Continue?" Message Box (https://www.excelbanter.com/excel-programming/451568-continue-message-box.html)

Paul Doucette

"Continue?" Message Box
 
I have code that runs when a command button is triggered, that does several things, including saving the file.
After that command button is triggered, and before the existing code runs, I would like to have a message box pop up as a warning with the option to either cancel or proceed, if any of the values on the worksheet €˜Start in cells B1, B2, B3, B4, B5, B7, B8, B9, and B10 have not changed.
By that I mean, I would like that message box to launch if any of the following is true: B1=Customer, B2=Item, B3=Diameter, B4=Length, B5=Species, B7=Machine, B8=Contact, B9=Item #, and B10=INQ# OR OLD PO#
All of those default values in those cells need to be changed to different values before allowing the code to run. Is this doable?
Thank you in advance!
Paul

Claus Busch

"Continue?" Message Box
 
Hi Paul,

Am Sun, 17 Jul 2016 13:30:31 -0700 (PDT) schrieb Paul Doucette:

I have code that runs when a command button is triggered, that does several things, including saving the file.
After that command button is triggered, and before the existing code runs, I would like to have a message box pop up as a warning with the option to either cancel or proceed, if any of the values on the worksheet ?Start? in cells B1, B2, B3, B4, B5, B7, B8, B9, and B10 have not changed.
By that I mean, I would like that message box to launch if any of the following is true: B1=?Customer?, B2=?Item?, B3=?Diameter?, B4=?Length?, B5=?Species?, B7=?Machine?, B8=?Contact?, B9=?Item #?, and B10=?INQ# OR OLD PO#?
All of those default values in those cells need to be changed to different values before allowing the code to run. Is this doable?


try following code before your existing code:

Sub Test()
Dim strVals As String
Dim varVals As Variant
Dim i As Long, j As Long

strVals = "Customer,Item,Diameter,Lenght,Species,Machine,Con tact,Item
#,INQ# OR OLD PO#"
varVals = Split(strVals, ",")

For i = LBound(varVals) To UBound(varVals)
j = i + IIf(i < 6, 1, 2)
If Cells(j, 2) = varVals(i) Then
MsgBox "Range B" & j & " is not changed", vbOKOnly
Exit Sub
End If
Next
'Your Code
End Sub


Regards
Claus B.
--
Windows10
Office 2016

Paul Doucette

"Continue?" Message Box
 
On Sunday, July 17, 2016 at 4:30:46 PM UTC-4, Paul Doucette wrote:
I have code that runs when a command button is triggered, that does several things, including saving the file.
After that command button is triggered, and before the existing code runs, I would like to have a message box pop up as a warning with the option to either cancel or proceed, if any of the values on the worksheet €˜Start in cells B1, B2, B3, B4, B5, B7, B8, B9, and B10 have not changed.
By that I mean, I would like that message box to launch if any of the following is true: B1=Customer, B2=Item, B3=Diameter, B4=Length, B5=Species, B7=Machine, B8=Contact, B9=Item #, and B10=INQ# OR OLD PO#
All of those default values in those cells need to be changed to different values before allowing the code to run. Is this doable?
Thank you in advance!
Paul


Claus-You make the complicated simple. I feel I could ask you for the formula for world peace, and you would only ask "Which world?" :-) That worked perfectly. And because my power of description was not up to including another step in my initial question, I will ask now.
On that same sheet if Cell B7=Molder, then I would like cell D8 to be checked along with the previous B1, B2, B3, B4, B5, B7, B8, B9, and B10. And if it's value has not been changed from it's default "Width", then the message box would be triggered.
Am I pushing my luck?
Thanks again for your kindness.
Paul

Claus Busch

"Continue?" Message Box
 
Hi Paul,

Am Sun, 17 Jul 2016 14:48:58 -0700 (PDT) schrieb Paul Doucette:

On that same sheet if Cell B7=Molder, then I would like cell D8 to be checked along with the previous B1, B2, B3, B4, B5, B7, B8, B9, and B10. And if it's value has not been changed from it's default "Width", then the message box would be triggered.


I don't know if I understood your problem clearly.
Try:

Sub Test()
Dim strVals As String
Dim varVals As Variant
Dim i As Long, j As Long

strVals = "Customer,Item,Diameter,Lenght,Species,Machine,Con tact,Item
#,INQ# OR OLD PO#"
varVals = Split(strVals, ",")

For i = LBound(varVals) To UBound(varVals)
j = i + IIf(i < 6, 1, 2)
If Cells(j, 2) = varVals(i) Then
MsgBox "Range B" & j & " is not changed", vbOKOnly
Exit Sub
End If
Next
If Range("B7") & Range("D8") = "MolderWidth" Then
MsgBox "D8 is not changed yet", vbOKOnly
Exit Sub
End If
'Your Code
End Sub


Regards
Claus B.
--
Windows10
Office 2016

Paul Doucette

"Continue?" Message Box
 
On Sunday, July 17, 2016 at 4:30:46 PM UTC-4, Paul Doucette wrote:
I have code that runs when a command button is triggered, that does several things, including saving the file.
After that command button is triggered, and before the existing code runs, I would like to have a message box pop up as a warning with the option to either cancel or proceed, if any of the values on the worksheet €˜Start in cells B1, B2, B3, B4, B5, B7, B8, B9, and B10 have not changed.
By that I mean, I would like that message box to launch if any of the following is true: B1=Customer, B2=Item, B3=Diameter, B4=Length, B5=Species, B7=Machine, B8=Contact, B9=Item #, and B10=INQ# OR OLD PO#
All of those default values in those cells need to be changed to different values before allowing the code to run. Is this doable?
Thank you in advance!
Paul


You understood (or guessed) perfectly. Thankyou Claus!!!!


All times are GMT +1. The time now is 09:46 AM.

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