Solved

Macro Code Revision - Types of Warning Messages?

Posted on 2013-01-20
14
221 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
  • 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
 
LVL 45

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 45

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 45

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 45

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 45

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now