LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Looping through textboxes

I'm not sure why you want to loop through the checkboxes. It looks like you
just want to check those 3 checkboxes.

I used 3 checkboxes from the Forms toolbar and this worked ok:

Option Explicit
Sub testme01()

Dim FDirect As String

FDirect = ""

With Worksheets("Program")
If .CheckBoxes("CheckBoxFx").Value = xlOn Then
FDirect = "FsX"
Else
If .CheckBoxes("CheckBoxFy").Value = xlOn Then
FDirect = "FsY"
Else
If .CheckBoxes("CheckBoxFz").Value = xlOn Then
FDirect = "FsZ"
End If
End If
End If
End With

MsgBox FDirect

End Sub

If I used a checkbox from the Control Toolbox toolbar, this worked:

Option Explicit
Sub testme02()

Dim FDirect As String

FDirect = ""

With Worksheets("Program")
If .CheckBoxFx.Value = True Then
FDirect = "FsX"
Else
If .CheckBoxFy.Value = True Then
FDirect = "FsY"
Else
If .CheckBoxFz.Value = True Then
FDirect = "FsZ"
End If
End If
End If
End With

MsgBox FDirect

End Sub

==================
That said, if you're trying to let the user choose one option from a few, you
may want to use Optionbuttons. And there are a couple of different types of
those, too--one on the Forms toolbar and one on the Control toolbox toolbar.

Be sure to include the type you used in any followup question.


CLamar wrote:

I am trying to loop through a group of textboxes that are on an excel sheet
(not in a userform) to see if they have been checked or not. How can I do
this. Below is what I have now.

Dim Ctrl As CheckBox

For Each Ctrl In Sheets("Program").CheckBoxes
If Sheets("Program").CheckBoxFx = True Then
FDirect = "FsX"
Else
If Sheets("Program").CheckBoxFy = True Then
FDirect = "FsY"
Else
If Sheets("Program").CheckBoxFz = True Then
FDirect = "FsZ"
End If
End If
End If
Next Ctrl


--

Dave Peterson
 
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
Looping in VB with cell ranges Freeman Excel Worksheet Functions 2 January 22nd 06 12:14 PM
control textboxes keep changing size Jimbolina Excel Discussion (Misc queries) 1 November 8th 05 05:49 AM
UserForm TextBoxes Rob Excel Discussion (Misc queries) 2 August 6th 05 03:07 AM
looping question luke New Users to Excel 4 June 3rd 05 01:19 PM
Textboxes and "Paste as picture" Eric Charts and Charting in Excel 6 March 5th 05 08:55 PM


All times are GMT +1. The time now is 10:58 PM.

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

About Us

"It's about Microsoft Excel"