Getting bored Try this

Steve
IF you paste the code into your VBA editor AND the first line is "Option Explicit" simply delete it.
If you want to turn it off for future "pastes", which is ill advised.
Open the VBA editor / tools / Options / Editor
and Check the "Require Variable Declaration" checkbox
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Code:
Sub test()
On Error Resume Next
Count = 0
Do
Count = Count + 1
Application.StatusBar = Application.WorksheetFunction.RandBetween(1, 1000000000)
Cells.Interior.Color = Application.WorksheetFunction.RandBetween(1, 1000000000)
Loop Until Count = 100
    
End Sub

I see what you mean - I had the same problem with the first code.

If you put a loop on and change the

"loop until Count" to a big number I think it has the same effect as the Original
 
Steve,

I think the idea of "turning on or off" Option Explicit is a bit misleading. Simply deleting the line at the top of the of your code screen (the Project Editor) that says "Option Explicit" will turn off or make it not apply to the code you are trying to run.

There is a way to apply this to all future workbooks, but I would suggest that whatever options you have that work for you not be altered with out a good understanding of what the impact would be. That said, you can set you options to always include Option Explicit by opening a VBA/Project Editor window, then choosing Options from the tools menu (not the Options menu when looking at a spreadsheet). On the Editor Tab, make sure there is a check in the radio box for "Require Variable Declaration". If the box is not checked, then you would have to type it in when you want to use it.
 

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