populate headers on combobox (rowsource) and skip the others

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
465
Office Version
  1. 2019
Hi

I want populating headers in combobox on userform based on headers in row1 for sheet2 and skip any column contains header ITEM (should not populate any column contains header ITEM into combobox) with considering should populate automatically when add new header by insert new column into combobox .
this is what I want to modify it .
VBA Code:
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim d As Object
Dim x

Set d = CreateObject("scripting.dictionary")
d.CompareMode = vbTextCompare
Set ws = Sheets("sheet2")
        For Each x In .Range("A1:D1" & .Cells(Rows.Count, "A").End(xlUp).Row).Value
          d(x) = Empty
        Next
Me.ComboBox1.List = d.Keys
End Sub
Thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,215,338
Messages
6,124,351
Members
449,155
Latest member
ravioli44

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