Link to home
Start Free TrialLog in
Avatar of Patrick O'Dea
Patrick O'DeaFlag for Ireland

asked on

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

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
ASKER CERTIFIED SOLUTION
Avatar of Steve
Steve
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Patrick O'Dea

ASKER

Ahhh!  Easym thanks!
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

Thank ML .... Some day that will be useful!