![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
|
Here's some code that will pop up multiple stars on a worksheet at one second intervals and then remove them.
Public Sub ShowStars() Randomize StarWidth = 50 StarHeight = 50 For i = 1 To 100 TopPos = Rnd() * (ActiveWindow.UsableHeight - StarHeight) LeftPos = Rnd() * (ActiveWindow.UsableWidth - StarWidth) Set NewStar = ActiveSheet.Shapes.AddShape _ (msoShape4pointStar, LeftPos, TopPos, StarWidth, StarHeight) NewStar.Fill.ForeColor.SchemeColor = Int(Rnd() * 56) Delay 0.01 DoEvents Next i Application.Wait Now + TimeValue("00:00:01") Set myShapes = Worksheets(1).Shapes For Each shp In myShapes If Left(shp.Name, 9) = "AutoShape" Then shp.Delete Delay 0.01 End If Next End Sub Public Sub Delay(rTime As Single) 'delay rTime seconds (min=.01, max=300) Dim oldTime As Variant 'safety net If rTime < 0.01 Or rTime > 300 Then rTime = 1 oldTime = Timer Do DoEvents Loop Until Timer - oldTime > rTime End Sub _________________ George [ This Message was edited by: GeorgeB on 2002-04-02 21:24 ] |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Perth Australia
Posts: 1,567
|
Hi George
That's cool man. Derek |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
|
Hi Derek
Glad you liked it. Pass it around down under. George
__________________
George Learn to listen. Opportunity sometimes knocks very softly. |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Hi George. I like this code. It's Amazing....
By the way I made a game using Cells.Interior.ColorIndex. it seems just like a snake is moving. ‚hthink you like the program which something moves on sheet. If you wish, I will mail it to you. Regards, |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
|
Hi Colo
Thanks for the offer, however my employer takes a dim view of receiving downloads from sources unknown to upper mgmt. I would like to see the code. If you could post it for all to see I'm sure it will get a lot of attention. Thanx George
__________________
George Learn to listen. Opportunity sometimes knocks very softly. |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
|
Colo,
I'd like to see the code. |
|
|
|
|
|
#7 |
|
New Member
Join Date: Mar 2002
Location: Fresno, CA USA
Posts: 5
|
This is pretty cool. Now how do you get it to run automatically when you open the workbook, or open a sheet within a workbook? Tom
|
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Hi all. I uploaded the file temporarily.
You can download the file at following url. If you able to open zip format(68.0 KB) http://www.rui-taka.co.jp/ExcelSnakeWW.zip else (198 KB) http://www.rui-taka.co.jp/ExcelSnakeWW.xls I created this game, in order to study VBA. I want you to see the codes and please let me know your comment. With Regards, Colo (I'm called corosuke in Jpn). |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
|
Tom
Put the code in either a workbook or a worksheet on activate module. Same way you get any code to run on open. George
__________________
George Learn to listen. Opportunity sometimes knocks very softly. |
|
|
|
|
|
#10 |
|
Board Regular
Join Date: Feb 2002
Posts: 165
|
Hi George,
Can you tell me how to run the code. I don't know how to even start the code. I'm pretty new to excel. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|