Consulting

Results 1 to 3 of 3

Thread: Solved: Useform autopopulate list box on opening the userform

  1. #1

    Solved: Useform autopopulate list box on opening the userform

    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.



    [VBA]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

    [/VBA]

  2. #2
    VBAX Contributor
    Joined
    Oct 2012
    Location
    Brisbane, Queensland, Australia
    Posts
    163
    Location
    See the following page of Greg Maxey's website :

    http://gregmaxey.mvps.org/Populate_UserForm_ListBox.htm



  3. #3
    Thanks Doug...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •