[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VBA Excel Statement     NM = MsgBox("Data has been clear", vbOKOnly, "New Month")

Posted on 2014-01-20
4
Medium Priority
?
482 Views
Last Modified: 2014-01-20
See

NM = MsgBox("Data has been clear", vbOKOnly, "New Month")

What does this mean?  I understand the bit to the right of the "=".

What does the bit to the left mean?

The NM (presumably "New Month") is never referred to again else where.
What purpose does it serve (since never referred to again)


Sub NewMonth()
    Application.ScreenUpdating = False
    Sheet48.Select
    Range("GoTo1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Range(Selection, Selection.End(xlToLeft)).Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Range("A1").Select
    Sheet38.Select
    Range("EvaDailyData").Select
    Selection.ClearContents
    Range("A1").Select
    Sheet29.Select
    Application.ScreenUpdating = True
    NM = MsgBox("Data has been clear", vbOKOnly, "New Month")
End Sub
0
Comment
Question by:Patrick O'Dea
[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
  • 2
4 Comments
 
LVL 24

Accepted Solution

by:
Steve earned 2000 total points
ID: 39793601
As you are using the vbOKOnly in the messagebox VBA is expecting a response of some kind to the messagebox question "is it OK".
So if you try the following you will see it wants a response, as it will error saying "expected =".

Sub test()
    MsgBox("Data has been clear", vbOKOnly, "New Month")
End Sub

Open in new window


The NM is just there to fulfill that requirement... it does nothing else and can be anything really.
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 39793609
Ahhh!  Easym thanks!
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39794454
Since you have already accepted an answer to this question I obviously don't expect any points but I feel I should make a couple of comments.

1) While as Steve pointed out MsgBox("Data has been clear", vbOKOnly, "New Month") will give you an error, MsgBox "Data has been clear", vbOKOnly, "New Month" won't. That's because the former is calling the MsgBox function expecting a return value, while the latter doesn't.

2) When you want to know what the user's response is you can do something like this.

NM = MsgBox("Do you want to clear the data?", vbYesNo, "New Month")
If NM = vbNo Then 
    Exit Sub
Else
    ' Clear the data
End If

Open in new window

0
 

Author Comment

by:Patrick O'Dea
ID: 39795300
Thank ML .... Some day that will be useful!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

656 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