I wanna get a value of selected item in a listbox. (the object is named "driver").
I am able to select one of two items:
"PostgreSQL Unicode(x64)"
"PostgreSQL ODBC Driver(Unicode)"
I need to use driver in an another code so I want to test how it works. In fact it does not work and msgbox driver returns blank/nothing
Here is may code:
I struggle what is wrong here?
I am able to select one of two items:
"PostgreSQL Unicode(x64)"
"PostgreSQL ODBC Driver(Unicode)"
I need to use driver in an another code so I want to test how it works. In fact it does not work and msgbox driver returns blank/nothing
Here is may code:
Code:
Option ExplicitDim driver As Variant
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Call the UserForm1 when click a cell
Dim ListBox1 As ListBox
If Selection.Count = 1 Then
If Not Intersect(Target, Range("C284")) Is Nothing Then
With UserForm1.ListBox1
.AddItem "PostgreSQL Unicode(x64)"
.AddItem "PostgreSQL ODBC Driver(Unicode)"
End With
Call ShowUserForm1
End If
End If
End Sub
Sub ShowUserForm1()
'show userform1 in the middle of Excel window
With UserForm1
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
.Show
End With
UserForm1.ListBox1.Value = driver
msgbox driver
End Sub
Last edited: