Consulting

Results 1 to 5 of 5

Thread: Some fun with message box????

  1. #1

    Some fun with message box????

    I have a couple of workbooks which when a macro button it is, it will save a copy and clear it down ready for new week.

    I'm due to have a week off work soon, and my manager gets really worried about things shes never done before. so I would like to trick her a little when I'm next off.
    Here is a sample of part of one of my codes with help from p45CAL!

    Could I sneak in AFTER the macros has finished.

    A box will pop up (preferably with a loading line) saying "deleting hard drive" with a cancel button, then when the cancel button is hit a message then saying "drive is corrupt, please contact I.T"



    [VBA]Sub CleardownSheets()
    Dim Response As Integer
    Response = MsgBox(prompt:="This will clear the sheet for a new week, are you sure?", Buttons:=vbYesNo)
    If Response = vbYes Then
    'Will now clear ranges if YES was selected
    Const PATH As String = "\\calfp03\Lynher Bakery\1AAMan Hours\current week\2013 - A1\1A WK"
    With ActiveWorkbook
    .SaveCopyAs Filename:=PATH & .Sheets("Reset Sheet").Range("A1").Value & ".xls"
    sApplication.ScreenUpdating = False
    ' Will clear all sheets in workbook
    Sheets("Sat Night (3)").Select
    Range("B5,D5:K5,O5:P5,B7,D7:K7,O7:P7,B9,D9:K9,O9:P9,B11,D11:K11,O11:P11,D13 :K13,O13:P13").Select Selection.ClearContents
    Application.ScreenUpdating = True
    ActiveWorkbook.Save
    End With
    Else
    ' The no button was selected.
    MsgBox "Action Was Cancelled"
    End If
    End Sub[/VBA]
    Last edited by Bob Phillips; 02-08-2013 at 02:51 AM. Reason: Tidied up the VBA

  2. #2
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    Add this to the bottom.

    [VBA]
    x = MsgBox("Deleting Hard Drive", vbOKCancel)
    x = MsgBox("Illegal Operation. Your hard drive is corrupted. Please contact your IT department", vbExclamation)
    [/VBA]

    I hope your boss has a good sense of humour. Personally I would add another line.

    [VBA]
    msgbox("HA HA Just kidding Mrs Boss")
    [/VBA]
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  3. #3
    Haha ideal I'll give this a go, and leave out the last bit.

    She won't even contact them, she'll be ringing me anyway.

    I have other ideas with the plain message boxes also, but Just thought there might have been one with some sort of loading bar to press cancel so to make it look more authentic?

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    perhaps a message along the lines of 'user has insufficient resources to complete this process. Insert new user and retry.'
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    ID-10T ERROR: error between user positioning system and user input interface
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

Posting Permissions

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