Transpose to Array

MM91

Board Regular
Joined
Nov 29, 2021
Messages
59
Office Version
  1. 365
Platform
  1. Windows
I want to make a macro that opens a workbook ("StandardParts") and then opens an excel userform(SearchUF) that has a textbox (userinput) then opens a worksheet ("StandardParts") and searches a worksheet ("List") Row C a for a match. Hi I am trying to write a code to get the values from row a and create a combo box list. I need it to search the column and then populate the combobox (combobox1) without duplicates. so the drop down list for this example would be "name1" "name2"' "name3". Any help is appreciated I am stuck thanks


Dim ws as worksheet
Dim List as varient


Sub Test()

Dim LastRow As Long

lastrow = Cells(Rows.count,1).Endxl(up).row

ws = activesheet

For i = 1 to Lastrow
if lastrow(i) <> cells(i,1) then
set List(i)
next i

End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi I am trying to write a code to get the values from row a and create a combo box list. I need it to search the column and then populate the combobox (combobox1) without duplicates. so the drop down list for this example would be "name1" "name2"' "name3"
I seem that your question is the one I quoted (above) and we can ignore the first part of your message.
Thus I suggest the following code:
VBA Code:
Dim LastRow As Long, I As Long
Dim CBList(), CBInd As Long, dataCol As String
'
dataCol = "A"                                      '<<< The column to look after
LastRow = Cells(Rows.Count, dataCol).End(xlUp).Row
ReDim CBList(1 To LastRow)
For I = 1 To LastRow
    If Application.WorksheetFunction.CountIf(Cells(1, dataCol).Resize(I, 1), Cells(I, dataCol).Value) = 1 Then
        CBInd = CBInd + 1
        CBList(CBInd) = Cells(I, dataCol)
    End If
Next I
ReDim Preserve CBList(1 To CBInd)
'Now you are ready to dump CBList to your Combobox
'for example:
UserForm1.ComboBox1.List = CBList                 '<<< Adapt

Try...
 
Upvote 0
Solution

Forum statistics

Threads
1,215,731
Messages
6,126,539
Members
449,316
Latest member
sravya

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top