Hello,
I'm using this code to copy listbox item to a textbox, however, I would like add the item without replacing everything in the textbox. Example : I write in the textbox "the apple is" and when I click the red item in the listbox, it completes the sentence. Is it possible?
thank you for your time
I'm using this code to copy listbox item to a textbox, however, I would like add the item without replacing everything in the textbox. Example : I write in the textbox "the apple is" and when I click the red item in the listbox, it completes the sentence. Is it possible?
thank you for your time
VBA Code:
Option Explicit
Public WithEvents TbTX As MSForms.TextBox
Dim cls() As New UserForm1
Public activeTxTbox As Object
Private Sub Listbox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
activeTxTbox = ListBox1.Value
End Sub
Private Sub ListBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With activeTxTbox: .SetFocus: .SelStart = Len(.Value): End With
End Sub
Private Sub TbTX_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Set UserForm1.activeTxTbox = TbTX
End Sub
Private Sub TbTX_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
End Sub
Private Sub UserForm_Activate()
Dim ctrl, a&
For Each ctrl In Me.Frame1.Controls
If TypeName(ctrl) = "TextBox" Then a = a + 1: ReDim Preserve cls(1 To a): Set cls(a).TbTX = ctrl
Next
End Sub
Private Sub UserForm_Initialize()
ListBox1.List = Array("red", "blue", "green", "black", "yellow")
End Sub