Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Linking textboxes with option boxes

I have a userform with a column of text boxes (TextBox1, 2, 3...10) and
adjacent Check boxes (CheckBox1, 2, 3...10).

The textboxes are populated from a sheet with various items.

What I need is for the adjacent Check boxes to be checked if the textboxes
contain either the text AAAAA or BBBBB and unchecked for anything else.

Can anyone help?

Many thanks,

Roger
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Linking textboxes with option boxes

And contains means that the textboxes can contain: xxxxxAAAAAyyyyy
and still be checked, right?

I only used 3 textboxes/checkboxes in this sample. You'll have to add 7 more
_Change procedures:

Option Explicit
Private Sub TextBox1_Change()
Call CheckTBoxCbx(WhichOne:=1)
End Sub
Private Sub TextBox2_Change()
Call CheckTBoxCbx(WhichOne:=2)
End Sub
Private Sub TextBox3_Change()
Call CheckTBoxCbx(WhichOne:=3)
End Sub
Sub CheckTBoxCbx(WhichOne As Long)

Dim myStrings As Variant
Dim sCtr As Long
Dim TboxValue As String
Dim OnOrOff As Boolean

myStrings = Array("aaaaa", "bbbbb")

TboxValue = Me.Controls("Textbox" & WhichOne).Value

OnOrOff = False
For sCtr = LBound(myStrings) To UBound(myStrings)
If InStr(1, Me.Controls("Textbox" & WhichOne).Value, _
myStrings(sCtr), vbTextCompare) 0 Then
'found one
OnOrOff = True
Exit For 'stop looking
End If
Next sCtr

Me.Controls("Checkbox" & WhichOne).Value = OnOrOff

End Sub

Remember to change the _change event name and pass the correct number.

Roger on Excel wrote:

I have a userform with a column of text boxes (TextBox1, 2, 3...10) and
adjacent Check boxes (CheckBox1, 2, 3...10).

The textboxes are populated from a sheet with various items.

What I need is for the adjacent Check boxes to be checked if the textboxes
contain either the text AAAAA or BBBBB and unchecked for anything else.

Can anyone help?

Many thanks,

Roger


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Linking textboxes with option boxes

Hi Roger,

"The textboxes are populated from a sheet with various items." Does this
mean they are populated with code?

Do you want the checkboxes updated as each textbox is updated or can they be
done in bulk like after a particular textbox is updated or with a button etc?


--
Regards,

OssieMac


"Roger on Excel" wrote:

I have a userform with a column of text boxes (TextBox1, 2, 3...10) and
adjacent Check boxes (CheckBox1, 2, 3...10).

The textboxes are populated from a sheet with various items.

What I need is for the adjacent Check boxes to be checked if the textboxes
contain either the text AAAAA or BBBBB and unchecked for anything else.

Can anyone help?

Many thanks,

Roger

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Linking textboxes with option boxes

Hi Ossie,

Yes, I use code to update the text boxes. It would be nice to have the
checkboxes respond to the textbox changes in the userform


Dave Peterson below has a nice solution for me that does update

Many thanks,

Roger


"OssieMac" wrote:

Hi Roger,

"The textboxes are populated from a sheet with various items." Does this
mean they are populated with code?

Do you want the checkboxes updated as each textbox is updated or can they be
done in bulk like after a particular textbox is updated or with a button etc?


--
Regards,

OssieMac


"Roger on Excel" wrote:

I have a userform with a column of text boxes (TextBox1, 2, 3...10) and
adjacent Check boxes (CheckBox1, 2, 3...10).

The textboxes are populated from a sheet with various items.

What I need is for the adjacent Check boxes to be checked if the textboxes
contain either the text AAAAA or BBBBB and unchecked for anything else.

Can anyone help?

Many thanks,

Roger

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Linking textboxes with option boxes

Thanks Dave,

This works nicely

Regards,

Roger

"Dave Peterson" wrote:

And contains means that the textboxes can contain: xxxxxAAAAAyyyyy
and still be checked, right?

I only used 3 textboxes/checkboxes in this sample. You'll have to add 7 more
_Change procedures:

Option Explicit
Private Sub TextBox1_Change()
Call CheckTBoxCbx(WhichOne:=1)
End Sub
Private Sub TextBox2_Change()
Call CheckTBoxCbx(WhichOne:=2)
End Sub
Private Sub TextBox3_Change()
Call CheckTBoxCbx(WhichOne:=3)
End Sub
Sub CheckTBoxCbx(WhichOne As Long)

Dim myStrings As Variant
Dim sCtr As Long
Dim TboxValue As String
Dim OnOrOff As Boolean

myStrings = Array("aaaaa", "bbbbb")

TboxValue = Me.Controls("Textbox" & WhichOne).Value

OnOrOff = False
For sCtr = LBound(myStrings) To UBound(myStrings)
If InStr(1, Me.Controls("Textbox" & WhichOne).Value, _
myStrings(sCtr), vbTextCompare) 0 Then
'found one
OnOrOff = True
Exit For 'stop looking
End If
Next sCtr

Me.Controls("Checkbox" & WhichOne).Value = OnOrOff

End Sub

Remember to change the _change event name and pass the correct number.

Roger on Excel wrote:

I have a userform with a column of text boxes (TextBox1, 2, 3...10) and
adjacent Check boxes (CheckBox1, 2, 3...10).

The textboxes are populated from a sheet with various items.

What I need is for the adjacent Check boxes to be checked if the textboxes
contain either the text AAAAA or BBBBB and unchecked for anything else.

Can anyone help?

Many thanks,

Roger


--

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
adding option boxes kb New Users to Excel 0 June 16th 07 02:51 PM
How do i create a value for check boxes or option boxes Tim wr Excel Discussion (Misc queries) 1 February 9th 06 10:29 PM
Linking List Boxes and Textboxes peter_rivera Excel Programming 4 June 22nd 05 08:46 PM
Problem with option boxes DDONNI[_4_] Excel Programming 1 November 3rd 04 12:28 PM
Linking textboxes to cells with formulae David Coleman[_2_] Excel Programming 7 December 29th 03 02:22 PM


All times are GMT +1. The time now is 03:22 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"