Home |
Search |
Today's Posts |
#11
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Adam,
No problem.......any time. Also, check out my reply to your last post. Conan " m wrote in message ... Conan, I got it to work! Thank you for your help. I think the problem was a missing parentheses. Thanks Again, Adam Bush "Conan Kelly" wrote: Adam, Please clear something up for me. In an earlier post, you said "I linked all the relevant cells to a range, however, when I type the following code:". What do you mean by "linked all the relevant cells to a range". Do you mean you gave it a name (Named Range). Also notice, this code is using the range CJ1:CJ143. Have you adjusted this code to use your range? Try the corrections below to see if it will keep you from getting that error message. Change the line that reads: If Application.CountIf(Range("CJ1:CJ143", 0)) = Range("CJ1:CJ143").Cells.Count Then To: If Application.WorksheetFunction.CountIf(Range("CJ1:C J143"), 0) = Range("CJ1:CJ143").Cells.Count Then See if that works. Post back and let me know what happens. HTH, Conan " m wrote in message ... Conan, I tried the code you provided but when I replaced OtherMacros with the name of my macro, I got an error. In VB, the first line was highighted in yellow and the messade said "Method 'Range' of object'_Global' failed". Any suggestions? Thanks Adam Bush "Conan Kelly" wrote: Bob, Please forgive me if I'm stepping on your toes. Please feel free to correct me if I get this wrong. Adam, In the line "Call OtherMacros", it is trying to run another macro named "OtherMacros". It is not likely that you have another macro nameed "OtherMacros". Replace "OtherMacros" with the name of your other macro that you want to run. Also, in order to get this to run, adjust the code like this: Sub sendwarning() If Application.CountIf(Range("CJ1:CJ143", 0)) = Range("CJ1:CJ143").Cells.Count Then If MsgBox("No Pivot Detected. Proceed Anyways?", vbOKCancel) = vbOK Then Call OtherMacros Else Msgbox "Canceled by user", vbOKOnly + vbInformation, "Canceled" Exit Sub End If Else Call OtherMacros End If End Sub Once again, remember to change "OtherMacros" in "Call OtherMacros" to the name of your macro that you want to run. HTH, Conan " m wrote in message ... Bob, I linked all the relevant cells to a range, however, when I type the following code: Sub sendwarning() If Application.CountIf(Range("CJ1:CJ143", 0)) = Range("CJ1:CJ143").Cells.Count Then If MsgBox("No Pivot Detected. Proceed Anyways?", vbOKCancel) = vbOK Then Call OtherMacros End If End If End Sub an error pops up saying "Sub or function not defined" which is referring to the Call OtherMacros section. Any ideas? Also, I want the button to run my other macro if the OK button is pushed OR if any of the cells in my range do not equal zero. How can I modify to incorporate this? Thanks Adam Bush "Bob Phillips" wrote: Sub myMacro If Application.CountIf(Range("A1:A100",0)) =Range("A1:A100").Cells.Count Then If MsgBox("Are you sure that you want to proceed?",vbOKCancel) =vbOK Then Call OtherMacros End If End If End SUb -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) " m wrote in message ... I have a command button on one of my worksheets and I want to add a conditional function to it. There are over a hundred cells in my worksheet that if they all equal zero and you push the button a dialogue box would appear with the message "Are you sure you want to proceed?" It would have two options, OK, or cancel, in which the attached macro would only run if the OK button was pushed. Is this possible? Any help would be greatly appreciated. Thanks Adam Bush |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
command button | Excel Worksheet Functions | |||
command button | Excel Discussion (Misc queries) | |||
Command Button Prompt Save As? | Excel Discussion (Misc queries) | |||
Command Button | Excel Worksheet Functions | |||
Command button | New Users to Excel |