Watch Object Example

The following routine prompts the user for a range, then loops through each cell in the range and adds it to the Watch window. It then displays the Watch window:

Sub AddWatches()

Dim oWatch As Watch

Dim rng As Range

Dim rngWatches As Range

'Prompt the user for a range

'Suppress the error if they cancel

On Error Resume Next

Set rngWatches = Application.InputBox( _

"Please select a cell or cell range to watch",

"Add Watch", , , , , , 8)

On Error GoTo 0

'If they selected a range

If Not rngWatches Is Nothing Then

'Loop through each cell and

' add it to the watch list

For Each rng In rngWatches

Application.Watches.Add rng

Next rng

End If

'View the watch window based on their answer

Application.CommandBars("Watch Window").Visible =

= (Not rngWatches Is Nothing)

End Sub

Was this article helpful?

0 0
The Accidental Blogging Millionaires

The Accidental Blogging Millionaires

Get Inspired By The Most Popular Bloggers Online! If You Want To Skyrocket Your Success With Business And Improve Your Overall Life You Need To Have A Look At The Accidental Blogging Millionaires! Business can be a fight, particularly when you’re trying to establish one online and like all fights, to succeed you must find the winning techniques and apply them.

Get My Free Ebook

Post a comment