Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Weird Do...Until behavior...

Below is a snippet from another thread. I have since figured out why the code
was halting, however... whenever the routine runs to add items into the
comboboxes, it's not catching the text/values to add...

I have textboxes/checkboxes on other pages that use:

cText = "My Text"
cValue = textbox1.text
call AddToCalcBox

and it isn't grabbing the values from cText and cValue They are both set to
be public so I *think* the code should carry the values back and forth, right?
I did notice that new lines are being added into the ComboBoxes, just not
the text/value. And another problem is whenever I type "1234" into a textbox,
there's 4 blank entries... instead of 1 blank entry.

This is really weird... any ideas?

Well damn. The code looked good, however... it's halting at
"Set Ctrl = projectinfo.multipage1.pages(7).Controls("calcbox" & i)"
with the error "Can't find the object specified" - Can't quite figure out
why, but I'll kepp pluggin' away...


"Incidental" wrote:

Hi

The code below should help you out or at least give you an idea of
where to start. To test add the code to a new module then on the
userform add a multipage, on the first page add a checkbox and on the
second page add as many comboboxes as you want.

'Add this code to a new module
Option Explicit
Dim CboBox() As New Class1
Dim Ctrl As Control
Dim i, X, Counter As Integer
Dim ChckVal
Sub AddToAllComboboxes()
ChckVal = UserForm1.MultiPage1.Pages(0).CheckBox1.Caption
i = 1
For Each Ctrl In UserForm1.MultiPage1.Pages(1).Controls
If TypeOf Ctrl Is MSForms.ComboBox Then
Set Ctrl =
UserForm1.MultiPage1.Pages(1).Controls("ComboBox" & i)
Ctrl.AddItem ChckVal
i = i + 1
End If
Next Ctrl
End Sub
Sub RemoveFromAllComboboxes()
i = 1
For Each Ctrl In UserForm1.MultiPage1.Pages(1).Controls
If TypeOf Ctrl Is MSForms.ComboBox Then
Set Ctrl =
UserForm1.MultiPage1.Pages(1).Controls("ComboBox" & i)
Counter = Ctrl.ListCount
X = 0
Do While X < Counter
Ctrl.ListIndex = (X)
If Ctrl.Value = ChckVal Then
Ctrl.RemoveItem Ctrl.ListIndex
End If
X = X + 1
Loop
i = i + 1
End If
Ctrl.Value = ""
Next Ctrl
End Sub

Then add this code to the click event of the checkbox

Private Sub CheckBox1_Click()
If UserForm1.MultiPage1.Pages(0).CheckBox1.Value = True Then
AddToAllComboboxes
Else
RemoveFromAllComboboxes
End If
End Sub

Hope this is of some help to you

S

PS isn't it hard to do IT on the Roof???




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
Weird Links Behavior Jon Oakdale Links and Linking in Excel 5 November 13th 08 08:44 AM
weird macro behavior Dave F Excel Discussion (Misc queries) 0 November 30th 06 03:35 PM
Excel weird behavior [email protected] Excel Discussion (Misc queries) 4 May 25th 06 08:23 PM
Weird clipboard behavior Josh Sale Excel Programming 0 July 6th 05 10:38 PM
Weird behavior of VLOOKUP John Simons Excel Programming 2 April 30th 05 02:21 AM


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