Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Error Handling Help

I have the following click event tied to CheckBox1 in a userform:

Private Sub CheckBox1_Click()
If CheckBox1 = True Then
Selection.SpecialCells(xlCellTypeFormulas, 23).Interior.ColorIndex = 6
ElseIf CheckBox1 = False Then
Selection.SpecialCells(xlCellTypeFormulas, 23).Interior.ColorIndex =
xlNone
End If
End Sub

I would like add the following features to be performed at the same time:

(1) display an error message if no formulas are found and
(2) turn the checkbox off (change the value to false).

When I try to set up the error handler, I seem to be getting caught in a
continuous loop. Can anyone suggest how to set up an efficient error
handling routine?

Thank you.

--
Steph
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error Handling Help

Option Explicit
Dim BlkProc As Boolean
Private Sub CheckBox1_Change()

Dim mySelection As Range

If BlkProc = True Then Exit Sub

Set mySelection = Nothing
On Error Resume Next
Set mySelection = Intersect(Selection, _
Selection.Cells.SpecialCells(xlCellTypeFormulas, 23))
On Error GoTo 0

If mySelection Is Nothing Then
msgbox "No formulas!"
BlkProc = True
Me.CheckBox1.Value = False
BlkProc = False
'maybe...
Selection.Interior.ColorIndex = xlNone
Else
If Me.CheckBox1.Value = True Then
mySelection.Interior.ColorIndex = 6
Else
mySelection.Interior.ColorIndex = xlNone
End If
End If

End Sub


Steph wrote:

I have the following click event tied to CheckBox1 in a userform:

Private Sub CheckBox1_Click()
If CheckBox1 = True Then
Selection.SpecialCells(xlCellTypeFormulas, 23).Interior.ColorIndex = 6
ElseIf CheckBox1 = False Then
Selection.SpecialCells(xlCellTypeFormulas, 23).Interior.ColorIndex =
xlNone
End If
End Sub

I would like add the following features to be performed at the same time:

(1) display an error message if no formulas are found and
(2) turn the checkbox off (change the value to false).

When I try to set up the error handler, I seem to be getting caught in a
continuous loop. Can anyone suggest how to set up an efficient error
handling routine?

Thank you.

--
Steph


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error handling Erik Wikström[_2_] Excel Programming 0 November 29th 07 01:56 PM
Error Handling Kirk P. Excel Programming 2 June 8th 07 03:19 PM
UDF Error Handling is ignored. Not for everyone? [email protected] Excel Programming 4 March 22nd 06 06:31 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM


All times are GMT +1. The time now is 01:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"