I'm preparing a Userform with plenty Textboxes and one listbox. I've apllied class module for all textboxes in Userform and when writing (change event) words at selected textbox I get dinamically updated listbox showing me possible words combination. Words shown in listbox are placed at worksheet. Now comes the problems. I want to click a word(value) from Listbox and automatically place that word(value) in selected textbox (textbox that click at the beggining). I've tried to declare a public variable to catch the name ** clicked textbox and then when selecting value from listbox, place that value to textbox variable name, but it doesn't work. What I'm doing wrong? Is it possible to create such a variable that storage Class module controls names and them easily refer to them when clicking any ** them?
thanks for help, it drives me crazy
If useful I'll attach a file
Code:
Standard Module called Module1
Public ClickedV As String
Public ActiveB As String
Private Sub mOtwieraUfAdder()
UFAdder.Show vbModeless
End Sub
Class module called Class1
Option Explicit
Public WithEvents TextGroup As MSForms.TextBox
Public Sub TextGroup_Change()
Dim c As Variant, d As Variant
d = ThisWorkbook.Sheets(1).Range("A1", Range("A" & Rows.Count).End(xlUp)).Value
ActiveB = TextGroup.value
msgbox ActiveB 'works
ActiveB.Value = "AnyValue" crashes "Invalid qualifier"
If TextGroup.Tag = "D" Then
With UFAdder.LList
.Clear
If Len(TextGroup.Value) = 0 Then Exit Sub
If IsNumeric(Application.Match("*" & .Value & "*", d, 0)) Then
For Each c In d
If LCase(c) Like "*" & LCase(TextGroup.Value) & "*" Then
.AddItem c
End If
Next c
End If
End With
End If
UserForm module called IFAdder
Dim Texts() As New Class1
Private Sub Userform_initialize()
Dim TCount As Integer
Dim Ctl As Control
TCount = 0
For Each Ctl In UFAdder.Controls
If TypeName(Ctl) = "TextBox" Then
TCount = TCount + 1
ReDim Preserve Texts(1 To TCount)
Set Texts(TCount).TextGroup = Ctl
End If
Next Ctl
End Sub
Sub LList_Click()
ActiveB.Value = LList.value this doesnt work even variable is declared as public, its like Excel doesnt recognize it as a textbox
LList.Clear
ActiveB.Value doesnt work
End Sub
If useful I'll attach a file