jocker_boy
Board Regular
- Joined
- Feb 5, 2015
- Messages
- 83
Hi,
I found this code:
and:
Sorry for not posting a image, but in my companies i can't find any site for hosting images that aren't block.
But the userform have 4 buttons: "Cancel"; "Clear"; "ALL"; "Ok".
This works perfect, because i need to select multiples strings to input in one cell.
However, i would like to input a diferent numerical number behind each string.
For example, if i have my strings:
ABC
DE
FGHI
JKL
MNOP
RST
I would like to select a cell, open a userform and have the possibility to write:
0,25 and pick ABC
1,00 and pick FGHI
0,75 and pick JKL
To input the cell this result:
"0,25ABC;1,00FGHI;0,75JKL"
Is this possible?
Many thanks in advance.
Gonçalo
I found this code:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo exitHandler
If Target.Column = 10 Then
gCountryListArr = Sheets("RESOURCES").Range("Table2[COD]").Value
gCellCurrVal = Target.Value
UserForm1.Show 'Pop up the form
Target.Value = gCellCurrVal
End If
exitHandler:
Application.EnableEvents = True
End Sub
and:
Code:
Private Sub CommandButton1_Click()
UserForm1.Hide 'Pop up the form
End Sub
Private Sub CommandButton2_Click()
For ii = 0 To ListBox1.ListCount - 1
Me.ListBox1.Selected(ii) = False
Next ii
End Sub
Private Sub CommandButton3_Click()
For ii = 0 To ListBox1.ListCount - 1
Me.ListBox1.Selected(ii) = True
Next ii
End Sub
Private Sub CommandButton4_Click()
gCellCurrVal = ""
For ii = 0 To ListBox1.ListCount - 1
If Me.ListBox1.Selected(ii) = True Then
If gCellCurrVal = "" Then
gCellCurrVal = Me.ListBox1.List(ii)
Else
gCellCurrVal = gCellCurrVal & ";" & Me.ListBox1.List(ii)
End If
End If
Next ii
UserForm1.Hide
End Sub
Private Sub UserForm_Activate()
On Error Resume Next
'On each activation, clear the whole,
'then add every country list element as blank
Me.ListBox1.Clear
For Each element In gCountryListArr
Me.ListBox1.AddItem element
Next element
UserForm_initialize
End Sub
Private Sub UserForm_initialize()
For Each element In Split(gCellCurrVal, ";")
For ii = 0 To ListBox1.ListCount - 1
If element = Me.ListBox1.List(ii) Then
Me.ListBox1.Selected(ii) = True
End If
Next ii
Next element
End Sub
Sorry for not posting a image, but in my companies i can't find any site for hosting images that aren't block.
But the userform have 4 buttons: "Cancel"; "Clear"; "ALL"; "Ok".
This works perfect, because i need to select multiples strings to input in one cell.
However, i would like to input a diferent numerical number behind each string.
For example, if i have my strings:
ABC
DE
FGHI
JKL
MNOP
RST
I would like to select a cell, open a userform and have the possibility to write:
0,25 and pick ABC
1,00 and pick FGHI
0,75 and pick JKL
To input the cell this result:
"0,25ABC;1,00FGHI;0,75JKL"
Is this possible?
Many thanks in advance.
Gonçalo