Good Excel Practical Jokes, Pranks, Mean Tricks, etc.

My fave:

Code:
Private Sub ok_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    i = Int((100 * Rnd) + 10)
    j = Int((100 * Rnd) + 10)
    ok.Left = i
    ok.Top = j
End Sub

Userform with "Click OK to continue".

You can add this to an ONTIME event to close the workbook after 10 seconds too.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I came up with this little annoyance:
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

Dim PlusMinus As Integer
Dim UpDown As Integer
Dim LeftRight As Integer

On Error Resume Next

Application.EnableEvents = False

PlusMinus = Rnd
    If PlusMinus > 0.4 Then
        UpDown = Rnd * 10
    Else
        UpDown = -Rnd * 10
    End If
    
PlusMinus = Rnd
    If PlusMinus > 0.4 Then
        LeftRight = Rnd * 10
    Else
        LeftRight = -Rnd * 10
    End If


    Target.Offset(UpDown, LeftRight).Select
Application.EnableEvents = True

End Sub
With this little code in the Workbook module you can never be sure where the cursor is going to be after the cell change.
 
Dunno if it's been posted or not, but in the sheet code where a user is required to enter numeric data

Code:
Private Sub Worksheet_Activate()
For i = 0 To 9
Application.OnKey i, ""
Next i
End Sub

Private Sub Worksheet_Deactivate()
For i = 0 To 9
Application.OnKey i
Next i
End Sub
 
Dunno if it's been posted or not, but in the sheet code where a user is required to enter numeric data

Code:
Private Sub Worksheet_Activate()
For i = 0 To 9
Application.OnKey i, ""
Next i
End Sub
 
Private Sub Worksheet_Deactivate()
For i = 0 To 9
Application.OnKey i
Next i
End Sub

Fun, but doesn't catch Num-Pad entries (at least not on my machine running 07 on vista)
 
Hi All
There's some great stuff in there....although I didn't read all of them.
This may have been mentioned earlier, but my eldest daughter was paranoid about her "files".....I wrote a simple Workbook_Open macro, that after a certain date changed the font in all cells white. It only lasted long enough to get a laugh and she took it pretty well !!
 
Code:
Private Sub Workbook_Open()
    Application.DisplayAlerts = False
    Randomize
    annoying_level = 100
    annoying_number = 100 * Rnd
    If annoying_number < annoying_level Then
        Application.Quit
    End If
End Sub

I've entered this into the VBA; but when i open it to test it (since i've put it to 100 it should close everytime) it doesnt seem to work

Am i doing something wrong or missing something?

-----------------
Using Excel 2003
 
Code:
Private Sub Workbook_Open()
    Application.DisplayAlerts = False
    Randomize
    annoying_level = 100
    annoying_number = 100 * Rnd
    If annoying_number < annoying_level Then
        Application.Quit
    End If
End Sub

I've entered this into the VBA; but when i open it to test it (since i've put it to 100 it should close everytime) it doesnt seem to work

Am i doing something wrong or missing something?

-----------------
Using Excel 2003

Hi flyingmonkeyofdoom,

It seems like it should work. I replaced Application.Quit with the following messagebox and it worked every time.

Code:
        MsgBox "Annoying number was: " & annoying_number & vbCrLf & vbCrLf & _
        "Annoying level was: " & annoying_level

Is it possible that your macros are not enabled or that your events aren't enabled?
 
or do you need to set the workbook as saved?
 
I've saved the file (and i've entered it under the tab and view code area)

Could be my computer or the event thing i suppose

I can get others to work on my computer; but i sent a file to a friend and it did nothing for them....

Might be i'm running 2003 and they have 2007....

Who knows; but i have till april to solve this
 

Forum statistics

Threads
1,223,723
Messages
6,174,113
Members
452,545
Latest member
boybenqn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top