Consulting

Results 1 to 7 of 7

Thread: msgbox help wanted

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    msgbox help wanted

    hello all
    i want to present several optios to a user .i want to have each option in a row.
    [VBA]
    Dim sheetpo As VbMsgBoxResult
    sheetpo = MsgBox("this sheet is to be: & vbCrLf &1.duplicated after last sheet (press yes)& vbCrLf & 2.it may be deleted (press no) " _
    , vbInformation + vbYesNoCancel, "sheet copy/delete")
    Select Case sheetpo
    Case vbYes
    ActiveSheet.Copy Before:=Sheets(Sheets.Count)
    Case vbNo
    ActiveSheet.Delete
    Application.DisplayAlerts = False
    Case vbCancel
    Exit Sub
    End Select

    [/VBA]
    thanks
    moshe

  2. #2
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    Try this:
    [VBA]Dim sheetpo As VbMsgBoxResult
    sheetpo = MsgBox("this sheet is to be: " & vbCrLf & _
    "1.duplicated after last sheet (press yes)" & vbCrLf & _
    "2.it may be deleted (press no) " _
    , vbInformation + vbYesNoCancel, "sheet copy/delete")
    Select Case sheetpo
    Case vbYes
    ActiveSheet.Copy Before:=Sheets(Sheets.Count)
    Case vbNo
    ActiveSheet.Delete
    Application.DisplayAlerts = False
    Case vbCancel
    Exit Sub
    End Select
    [/VBA]
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    sheetpo = MsgBox("this sheet is to be:" & vbNewLine & _
                             "1.duplicated after last sheet (press yes)" & vbNewLine  & _
                             "2.it may be deleted (press no) ", _ 
                             vbInformation + vbYesNoCancel, "sheet copy/delete")
    apprently vbNewLine works with Macs so is more generic
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    For what it's worth, I've gotten in the habit of using a standard title in all macros that use Msgbox:
    [vba]Constant Title As String = "'Workbkname' (macroname)'"
    '. . .
    Msgbox "My msg text", vbOKCancel, Title[/vba] This can be quite useful when wondering where a particular message was issued.

  5. #5
    VBAX Regular
    Joined
    Jun 2007
    Posts
    69
    Location
    Quote Originally Posted by Cyberdude
    For what it's worth, I've gotten in the habit of using a standard title in all macros that use Msgbox:
    [vba]Constant Title As String = "'Workbkname' (macroname)'"
    '. . .
    Msgbox "My msg text", vbOKCancel, Title[/vba] This can be quite useful when wondering where a particular message was issued.
    Brilliant!

    Wonderful suggestion.

    Ron
    Orlando, FL
    Ron McKenzie
    Windermere, FL
    (living in the huge shadow of a tiny rodent)

  6. #6
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Quote Originally Posted by Cyberdude
    For what it's worth, I've gotten in the habit of using a standard title in all macros that use Msgbox:
    [vba]Constant Title As String = "'Workbkname' (macroname)'"
    '. . .
    .
    Is there anyway..that the Workbook name and Macroname..be assigned dynamically..stored in two variables..and the Title be 'built'....??

    Instead of each time..hardcoding it in...?


    regards,

    asingh

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Workbook name is simple

    myWb = Activeworkbook.Name

    Macroname is not easy, ther is no object exposed.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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