(Solved) – In VBA code,how to add values to a listbox using for each cell approach with defining a range End(XlDown)?

  • by
(solved)-–-in-vba-code,how-to-add-values-to-a-listbox-using-for-each-cell-approach-with-defining-a-range-end(xldown)?

I have created a macro file with Forms and Word to Excel.

In this coding fewthings are not working as per my expectation.

  1. Get unique Employee Name from Excel data base.
    I want to add unique employee names from excel database and get is saved in a sheet. After that those values to be added to list box. Here i cannot define a range like “A1:A10”.. I want to choose the data from A1 to end data.

If for each cell approach will not work, please help in do while approach

I need help in defining the range and code given below

ListEmployeeName.Clear
For Each cell In Worksheets("SunEmployeeDetails").Range("A1").End(xlDown)
    ListEmployeeName.AddItem (cell.Value)
Next
    ListEmployeeName.Value = Worksheets("SunEmployeeDetails").Range("A1")
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *