kevvukeka
06-11-2013, 02:11 AM
Hi All,
I am trying to autpopulate a list box with value when I open the the userform. Below is the code for it. But the list box doesn't get populated.
Can someone show whats the error. Kindly help.
Sub RoundedRectangle1_Click()
Dim t As Integer
Dim Trng As Range
Dim ws As Worksheet
UserForm1.Show
Sheets("Policy_Details").Range("BA:BA").ClearContents
't = Sheets("Policy_Details").Cells(Rows.Count, "A").End(xlUp).Row
Set ws = Worksheets("Policy_Details")
Set Trng = ws.Range("A:A")
Trng.Select
Selection.Copy ws.Range("BA1")
ws.Range("BA:BA").RemoveDuplicates Columns:=1, Header:=xlNo
ws.Range("A1").Select
t = ws.Cells(Rows.Count, "BA").End(xlUp).Row
UserForm1.lstYear.List = ws.Range("BA2:BA" & t).Value
End Sub
I am trying to autpopulate a list box with value when I open the the userform. Below is the code for it. But the list box doesn't get populated.
Can someone show whats the error. Kindly help.
Sub RoundedRectangle1_Click()
Dim t As Integer
Dim Trng As Range
Dim ws As Worksheet
UserForm1.Show
Sheets("Policy_Details").Range("BA:BA").ClearContents
't = Sheets("Policy_Details").Cells(Rows.Count, "A").End(xlUp).Row
Set ws = Worksheets("Policy_Details")
Set Trng = ws.Range("A:A")
Trng.Select
Selection.Copy ws.Range("BA1")
ws.Range("BA:BA").RemoveDuplicates Columns:=1, Header:=xlNo
ws.Range("A1").Select
t = ws.Cells(Rows.Count, "BA").End(xlUp).Row
UserForm1.lstYear.List = ws.Range("BA2:BA" & t).Value
End Sub