Solved

Macro Code Revision - Types of Warning Messages?

Posted on 2013-01-20
14
238 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 46

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 46

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 46

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 46

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 46

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

810 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