VBA Prank

msk7777

Active Member
Joined
Mar 30, 2004
Messages
280
I was wanting to play a trick on a few people in my department. I want to put a code in that when they enter any information in any cells it will post some type of message (lets just say for now I want it to say "xls. file corrupt, please close document and contact your Network Administrator"). Can anyone help me do this? Not to familar with VBA. Thanks!

msk7777
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Those are all great tricks, but for someone like me I don't know how to do these, none of them really explain how to go about doing it.
 
Those are all great tricks, but for someone like me I don't know how to do these, none of them really explain how to go about doing it.
Hi,
depends what you mean by "explain"
for instance this code needs no explanation, supposed you know where to put the code...
Code:
Private Sub Workbook_Open() 
Application.DisplayAlerts = False 
Application.Quit 
End Sub
if you have questions about how to use, my suggestion would be to post it in the "Excel Questions" forum

your original question ...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox "xls. file corrupt, please close document and contact your Network Administrator", 48, "ERROR"
End Sub
see http://www.cpearson.com/excel/events.htm

to make it more "real" you could let the code wait till 30 changes are made
then there is a chance of 1/10 (Rnd < 0.1) to get the popup
(change like you want)
in a "standard" module
Code:
Global cnt As Integer
in the sheetmodule
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
cnt = cnt + 1
If cnt > 30 And Rnd < 0.1 Then MsgBox "xls. file corrupt, please close document and contact your Network Administrator", 48, "ERROR"
End Sub
alternatively in the workbookmodule
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
cnt = cnt + 1
If cnt > 30 And Rnd < 0.1 Then MsgBox "xls. file corrupt, please close document and contact your Network Administrator", 48, "ERROR"
End Sub
remind: if you have more technical questions post in the "Excel Questions" forum, not in this chat-forum :)

kind regards,
Erik
 
To be honest I don't know how this got moved into this forum, I posted it originally in Excel Questions. When I say "explained" I mean I don't really know how or where to put those codes, they look like fun and I want to play those pranks but I don't know how.

msk7777
 
:eek: It's been a while since I've read that thread in its entirety, but as I recall there were a couple of ideas in there that bordered on dangerous (or I might be remembering an older "funny pranks" thread in the old lounge). If you don't know what you're doing, proceed with caution. VBA pranks can be funny in the hands of a benevolent but orny feller who knows what he's doin'. VBA pranks might getcha fired if you accidentally blow something up. :eek:
 
When I say "explained" I mean I don't really know how or where to put those codes, they look like fun and I want to play those pranks but I don't know how.
even not after reading my reply ? did you check out the link (with extensive explanations)
 
I put the code into a module, saved and closed out of the workbook opened it back up and made some changes to the workbook and nothing happened? Did I maybe miss something?
 
No offense, but I agree with Greg. They are funny to talk about or show a friend, but most of those things you wouldn't want to actually do. And if you DO do them you would want to make sure there was no real damage. As a rule, if you aren't sure how code works or what it does you shouldn't use it in production. And when the code is pretty much guarenteed to cause trouble it is even less advisable. Remember that for every person causing trouble with a feature there are 5 that will scream to MS to make that feature less accessable.
 
I put the code into a module, saved and closed out of the workbook opened it back up and made some changes to the workbook and nothing happened? Did I maybe miss something?
reading this it is like you've put everything in one single module, instead of following my explanation :confused: (which is straightforward to my sense)

of course agree with Greg: certainly when you do not know what you're doing
 

Forum statistics

Threads
1,213,534
Messages
6,114,188
Members
448,554
Latest member
Gleisner2

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