Solved

Macro Code Revision - Types of Warning Messages?

Posted on 2013-01-20
14
260 Views
Last Modified: 2013-01-26
Hello Experts,

I am currently using this code,...

Sub ClearMeasuringUp()
    If MsgBox("You are about to clear the entire worksheet - Are you sure you want to proceed?", vbYesNo) = vbYes Then
        ActiveSheet.Range("B28:D28,F28:H28,J28:L28,P28").ClearContents
        ActiveSheet.Range("N27").Value = "Diameter"
        Application.Goto Reference:="Diameter"
        Selection.ClearContents
    End If
End Sub

My question, is specific to this line of code...

    If MsgBox("You are about to clear the entire worksheet - Are you sure you want to proceed?", vbYesNo) = vbYes Then

Here is a screenshot of how the viewer sees it.

Warning Message
Now here's my question...

Are there other types of popup messages?  For example, as you can see my message is put into the body of the popup.  Is there a piece of code that controls the title of that window? Is there a piece of code that maybe shows a lil stop/warning/information icon?

Any ideas?

Thank you in advance for your help!

~ Geekamo
0
Comment
Question by:Geekamo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
  • +1
14 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38799199
If MsgBox("You are about to clear the entire worksheet - Are you sure you want to proceed?", vbYesNo,"Your warning title") = vbYes Then


I do not think you can put an icon in there.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38799201
For an icon you probably would have to revert to userforms
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 38799226
You do have some icon options.  For example:

' Question mark

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you want to proceed?", vbYesNo + vbQuestion, _
    "Your warning title") = vbYes Then

Open in new window


' Exclamation point

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you wait to proceed?", vbYesNo + Exclamation, _
    "Your warning title") = vbYes Then

Open in new window


' Error

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you want to proceed?", vbYesNo + Critical, _
    "Your warning title") = vbYes Then

Open in new window


' Information

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you want to proceed?", vbYesNo + vbInformation, _
    "Your warning title") = vbYes Then

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 48

Expert Comment

by:Martin Liss
ID: 38799244
There are several options you can use.
several
0
 
LVL 1

Author Comment

by:Geekamo
ID: 38799245
@ matthewspatrick,

I am using...

' Exclamation point

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you wait to proceed?", vbYesNo + Exclamation, _
    "Your warning title") = vbYes Then

But this is what it shows,...

Missing Icon
It doesn't include the exclamation point.

Any ideas?

~ Geekamo
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 38799253
try VBExclamation
0
 
LVL 1

Author Comment

by:Geekamo
ID: 38799259
@ MartinLiss,

I'm not sure what "try VBExclamation" means.
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 38799260
Yes this works fine.

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you wait to proceed?", vbYesNo + vbExclamation, _
    "Your warning title") = vbYes Then...
0
 
LVL 1

Author Comment

by:Geekamo
ID: 38799271
@ MartinLiss,

Your code,...

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you wait to proceed?", vbYesNo + vbExclamation, _
    "Your warning title") = vbYes Then

Results in this,...

Excel Icon
Clearly it's showing the excel icon, and not an exclamation icon.  I wonder if we're now getting into the area of me using Excel on Mac.  Is it different somehow?

The icon would be great, but it's not the end of the world.  If there isn't a easy fix, then I might just go with "ID: 38799199" because it at least gets me the title.

Anyhow, let me know your thoughts.

~ Geekamo
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 38799282
Well it's not that clear:)
FromVBAAre you using VBA in Excel 2010 for that message?
0
 
LVL 1

Author Comment

by:Geekamo
ID: 38799305
@ MartinLiss,

Excel Version
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 38799312
Oh, that's Excel for the MAC not for the PC, so, sorry, I can't help you.
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 38799400
Geekamo,

Sorry, the code in my post should have been:

' Question mark

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you want to proceed?", vbYesNo + vbQuestion, _
    "Your warning title") = vbYes Then

Open in new window


' Exclamation point

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you wait to proceed?", vbYesNo + vbExclamation, _
    "Your warning title") = vbYes Then

Open in new window


' Error

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you want to proceed?", vbYesNo + vbCritical, _
    "Your warning title") = vbYes Then

Open in new window


' Information

If MsgBox("You are about to clear the entire worksheet - " & _
    "Are you sure you want to proceed?", vbYesNo + vbInformation, _
    "Your warning title") = vbYes Then

Open in new window

0
 
LVL 1

Author Comment

by:Geekamo
ID: 38823216
Thank you all! ~ Geekamo
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question