Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 15th, 2006, 01:17 PM
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default recursive checkbox procedure?

I am writing a simple procedure to uncheck a checkbox if a certain condition is met but I think it is executing the whole procedure on value change. Try pasting this code into excel after creating a checkbox. Not sure why the msgbox comes up again after I click on no.

Private Sub CheckBox1_Click()
Dim s As Integer

s = MsgBox("Delete numbers?", vbYesNo)
If s = vbYes And CheckBox1 = True Then
    'Do stuff
Else
    'erase tick in checkbox since nothing was done
    CheckBox1 = False
    'This is where it brings up the msgbox again which it shouldn't
End If

End Sub


Thanks!

 
Old August 16th, 2006, 09:54 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this one

Private Sub CheckBox1_Click()
Dim s As Integer
Static i As Integer

If i = 1 Then
    i = 0
    Exit Sub
End If

s = MsgBox("Delete numbers?", vbYesNo)
If s = vbYes And CheckBox1 = True Then
    'Do stuff
Else
    'erase tick in checkbox since nothing was done
    i = i + 1
    CheckBox1.Value = False

    'This is where it brings up the msgbox again which it shouldn't
End If

End Sub

-vemaju





Similar Threads
Thread Thread Starter Forum Replies Last Post
Recursive template - Please Help! Tre XSLT 5 March 20th, 2007 11:23 AM
checkbox checked by default by html:checkbox sachin.tathod Struts 3 December 4th, 2006 03:41 PM
Recursive Function MargateFan XSLT 2 May 4th, 2006 02:52 AM
recursive XSLT Help boates XSLT 2 January 11th, 2006 03:50 PM
Recursive Stored Procedure ramk_1978 SQL Language 2 June 30th, 2005 09:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.