Consulting

Results 1 to 3 of 3

Thread: Message Box Code!

  1. #1

    Message Box Code!

    I am now writing a macro.

    This macro shows a message box to have following message

    "Macro Macro1 has been completed."

    Right now I would like to have three message instead of one.

    i.e.

    "Macro Macro1 has been completed."

    "The running begin at XX:XXpm"

    "The running end at XX:XXpm"

    "The total running time is yy min"

    how could I modify below code to reach 4 message in separate line instead of one.

    Many Thanks,

    Sub Starting()
    Dim MacroName, StartTime, EndTime, TimeDiff

    MacroName = "Macro1"
    Application.Run MacroName
    Msg = "Macro" & MacroName & "has been completed."
    Style = vbOKOnly
    Title = "Macro Message Box"
    Help = "DEMO.HLP"
    Ctxt = 1000
    Response = MsgBox(Msg, Style, Title, Help, Ctxt)

    End Sub

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Hi i dont knw how to do the timings in your message box but i have split the message box p ready for your timer variables

    [VBA]
    MsgBox "Macro" & MacroName & "has been completed." & Chr(13) & "The running begin at " & "XX:XX" & Chr(13) & "The running end at " & "XX:XXpm" & Chr(13) & "The total running time is " & "yy min", vbOKOnly, "Macro Message Box", "Demo.help", 1000
    [/VBA]Regards,
    Simon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub Starting()
    Dim MacroName As String
    Dim StartTime As Double
    Dim EndTime As Double
    Dim TimeDiff As Double

    StartTime = Now
    MacroName = "Macro1"
    Application.Run MacroName
    EndTime = Now
    TimeDiff = EndTime - StartTime
    Msg = "Macro " & MacroName & "has been completed." & vbNewLine & _
    "The running began at " & Format(StartTime, "hh:mm AM/PM") & vbNewLine & _
    "The running finished at " & Format(EndTime, "hh:mm AM/PM") & vbNewLine & _
    "Total run time was " & Round(TimeDiff * 24 * 60 * 60, 1) & " seconds"
    Style = vbOKOnly
    Title = "Macro Message Box"
    Help = "DEMO.HLP"
    Ctxt = 1000
    Response = MsgBox(Msg, Style, Title, Help, Ctxt)

    End Sub
    [/vba]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •