![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Hengelo
Posts: 79
|
Hello again,
In column A I have words. In column B I have categories, e.g. A, B, C. What I want is that only the words of category B appear in a combobox on a userform. How do I program that in VB?
__________________
Best regards, Martin J.A. Maatman Oonk |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
Martin,
I am particularly fond of the cells array, but I'm sure you could do it many other ways. This example assumes the values start in row 1. If you have a header row, you would start the For loop with the first row of data. It also assumes the sheet with the data is called SheetName. Dim i as Long ComboBox1.Clear With Sheets("SheetName") For i = 1 to 65000 If .Cells(i,1).value = "" Then Exit For If .Cells(i,2).value = "B" Then ComboBox1.AddItem .Cells(i,1) End If Next End With |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|