Getting bored Try this

prajul89

Active Member
Joined
Jul 9, 2011
Messages
404
:rofl:
Code:
Sub test()
On Error Resume Next
Application.StatusBar = Application.WorksheetFunction.RandBetween(1, 1000000000)
    Cells.Interior.Color = Application.WorksheetFunction.RandBetween(1, 1000000000)
    Application.OnTime Now, "test"
End Sub

Remember this macro will run continuously. to stop it Break it by pressing Ctrl+Break.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
similar idea to this one.

Code:
Sub playing()
With Cells
    .Interior.ColorIndex = xlNone
    .ColumnWidth = 0.75
    .RowHeight = 6
End With
ActiveWindow.Zoom = 85
ActiveWindow.Zoom = 70


rght = 1
dwn = 1
lft = 2
up = 2
Range("da70").Select

Selection.Interior.ColorIndex = 1

rghttest = 0
dwntest = 0
lfttest = 0
uptest = 0


Do Until rght > 100
    Do Until rghttest = rght
        rghttest = rghttest + 1
        Selection.Offset(0, 1).Select
        Selection.Interior.ColorIndex = Int((55 - 1 + 1) * Rnd + 1)
    Loop

    rght = rght + 2
    rghttest = 0

    Do Until dwntest = dwn
        dwntest = dwntest + 1
        Selection.Offset(1, 0).Select
        Selection.Interior.ColorIndex = Int((55 - 1 + 1) * Rnd + 1)
    Loop

    dwntest = 0
    dwn = dwn + 2

    Do Until lfttest = lft
        lfttest = lfttest + 1
        Selection.Offset(0, -1).Select
       Selection.Interior.ColorIndex = Int((55 - 1 + 1) * Rnd + 1)
    Loop

    lfttest = 0
    lft = lft + 2

    Do Until uptest = up
        uptest = uptest + 1
        Selection.Offset(-1, 0).Select
        Selection.Interior.ColorIndex = Int((55 - 1 + 1) * Rnd + 1)
    Loop

    uptest = 0
    up = up + 2

Loop

Selection.Interior.ColorIndex = 0

End Sub
 
Steve
Are you using option explicit ??
If so, turn it off and rerun.

Reaaly, really, exciting....not !!
 
Steve
Are you using option explicit ??
If so, turn it off and rerun.

Reaaly, really, exciting....not !!

I have no idea what "Option Explicit" is or how to turn it on or off.
So I Googled "Option Explicit" and wound up here:

http://www.actuarialoutpost.com/actuarial_discussion_forum/showthread.php?t=97489

and I clicked on the "[ ] require variable definition" button both ways and
nothing happened on either trial.

So, I gather that the cells are supposed to blink nice random patterns of color
or some such and some how "option explicit off" allows that to happen.


 
Option explicit appears as text in the line above your Sub, if you have it turned on.
Your description of the "nice random patterns" is spot on !!!
 
Declared my variables now.

Code:
Option Explicit

Sub playing()

Dim rght As Single
Dim dwn As Single
Dim lft As Single
Dim up As Single
Dim rghttest As Single
Dim dwntest As Single
Dim lfttest As Single
Dim uptest As Single


With Cells
    .Interior.ColorIndex = xlNone
    .ColumnWidth = 0.75
    .RowHeight = 6
End With
ActiveWindow.Zoom = 85
ActiveWindow.Zoom = 70


rght = 1
dwn = 1
lft = 2
up = 2
Range("da70").Select

Selection.Interior.ColorIndex = 1

rghttest = 0
dwntest = 0
lfttest = 0
uptest = 0


Do Until rght > 100
    Do Until rghttest = rght
        rghttest = rghttest + 1
        Selection.Offset(0, 1).Select
        Selection.Interior.ColorIndex = Int((55 - 1 + 1) * Rnd + 1)
    Loop

    rght = rght + 2
    rghttest = 0

    Do Until dwntest = dwn
        dwntest = dwntest + 1
        Selection.Offset(1, 0).Select
        Selection.Interior.ColorIndex = Int((55 - 1 + 1) * Rnd + 1)
    Loop

    dwntest = 0
    dwn = dwn + 2

    Do Until lfttest = lft
        lfttest = lfttest + 1
        Selection.Offset(0, -1).Select
       Selection.Interior.ColorIndex = Int((55 - 1 + 1) * Rnd + 1)
    Loop

    lfttest = 0
    lft = lft + 2

    Do Until uptest = up
        uptest = uptest + 1
        Selection.Offset(-1, 0).Select
        Selection.Interior.ColorIndex = Int((55 - 1 + 1) * Rnd + 1)
    Loop

    uptest = 0
    up = up + 2

Loop

Selection.Interior.ColorIndex = 0

End Sub
 
Option explicit appears as text in the line above your Sub, if you have it turned on.

Your description of the "nice random patterns" is spot on !!!
I do love this site, and this little topic is realy trivial,

B U T

so far I've been told that I need to turn off Option Explicit and I'm also told
what I should see if I have it turned on or off, but there hasn't been any
instructions forthcoming as to exactly how to, key stroke by key stroke, turn
it on or off.

(-:





 
Option explicit either allows or disallows the use of undefined variables.

The first line of my code

"Option Explicit"

This turns it on in effect.


There is no user selectable option.



To get the code to work.

0. I would suggest closing all other work books down - Don't want this to run on your proper work books!!!

1. Open a new Book.

2. Right Click "Sheet 1"

3. Click View Code

4. In Project viewer your should see VBAProject("Book 1")

5. Right click > INSERT > MODULE

6.Module1 will now be present.

7. Paste the code into this module

"From OPTION EXPLICIT ..... END SUB"

8.Close VBA

9Go to your Macro menu (depend which version you are using)

10. Run the macro called PLAYING
 

Forum statistics

Threads
1,222,622
Messages
6,167,137
Members
452,098
Latest member
xel003

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