Populating Combobox (ActiveX) Using Variable

Mar 19, 2014

I have 100 combo boxes on an excel sheet, they are divided in three sets (1-25, 26-50, 51-100). Each set has the same value within the set, but is different from the other.

Right now I am able to populate the combo boxes using the following code

Code:
ActiveSheet.ComboBox1.AddItem "Value1"
ActiveSheet.ComboBox1.AddItem "Value2"
ActiveSheet.ComboBox1.AddItem "Value3"
^ This is time consuming and error prone. Is there a way I can use a variable to populate the combo boxes?

I have been able to find the following code, but it does not work.

Code:
Dim ComboBox As ObjectFor ComboBoxCalc1 = 1 To 25
Set ComboBox = ComboBox(ComboBoxCalc1).Select
ActiveSheet.ComboBox(ComboBoxCalc1).AddItem "Value1"
ActiveSheet.ComboBox(ComboBoxCalc1).AddItem "Value2"
ActiveSheet.ComboBox(ComboBoxCalc1).AddItem "Value3"
Next

View 6 Replies


ADVERTISEMENT

Populating Combobox 2 With Items That Match Criteria From Combobox 1

Mar 30, 2009

Am trying to get dynamic population of 2nd combobox based on match from criteria in combobox 1.

if column a = bears and column b = colours of bears then

when I select bears in combobox one, combobox 2 would populate with colors of bear.

I am think of having a combobox 1 change event that evaluates each row in a specific range (does it match the criteria?) if so, then add 2nd cell (column b) of that row to the combobox 2.

I know it would probably involve match and offset, add item and loop, but I am not sure what the syntax is.

View 9 Replies View Related

Use Activex Combobox In The Worksheet

Jan 5, 2008

successfully use Activex combobox on the worksheet, (excel 2003)
without the code from other boxes being triggered at random.

Or should I give this up, and use a form to house these controls? ( I have no Knowledge on this)

I've tried certain IF then statements to protect the excecutable, but it seems, that, even boxes in other books are looked at, with a simple call statement (to a macro in module)

Having a real problem in Isolating these things.

Try to get the code to activate when you select the same Item twice, It seems none of the procedures do this. I made a workaround with using two procedures, but it's a bit clumsy.

View 9 Replies View Related

ActiveX Combobox Code-run

Jun 4, 2009

I've created a workbook on whose main sheet there are three activex comboboxes. The first one contains a list of years, and the second one contains a list of months. The user selects the year, and it goes to its linked cell. The user then selects a month, and using the Combobox_Click event, should run a sequence of 7 macros (i.e. using the "call updateinformation1" macro, which is the first of the seven updateinformation macros).

The sequence of macros ran fine before I added the comboboxes. After adding the comboboxes, the final (7th) macro somehow goes back to the first macro and then causes a "ClearContents method of Range class failed" error on the "Selection.ClearContents" line. These are the first and seventh macros:

Sub updateinformation1()
'clears previous information to make way for new information
Application.ScreenUpdating = False
Application.EnableEvents = False

Worksheets("Criteria2").Activate
Cells.Select
Selection.ClearContents

I can't for the life of me figure out why it's looping back to the first macro instead of just stopping after the seventh. I have other workbooks that do something similar, and I don't have this problem. Am I missing something?

if I need to post all 7 macros?

View 9 Replies View Related

Add Scroll Arrow To ActiveX Combobox?

Mar 20, 2013

I have an application were I would like to use an Active X combo box instead of a regular dropdown list. The list contains 64 items and the text becomes very small in a standard dropdown list. Using an Active X Combo Box allows me to enlarge the text for easier viewing but with 64 items the list tends to run off the sheet. Is their a switch or some other way (scrolling) to make it more viewer friendly?

View 5 Replies View Related

Filter Column Using ActiveX Combobox?

Aug 1, 2013

I am trying to use a combo box with a defined list I have in another worksheet.

I was able to name and populate the list into the combo box, but am trying to work a macro into it.

I have a large data sheet with with many columns. In this worksheet, I also placed the combo box. What I would like to do is to be able to click on a name in the combo box and have it filter Column H, where there are many data points.

For example, In column H I have Apples, Watermelons, Peaches, etc.

In the combo box list, I would like to click on Apples and Column H list only the Apple names. Then if I want to click on Watermelons, it would filter Column H to only those which have Watermelons listed...

View 1 Replies View Related

Can't Change Combobox Properties (activex)

Apr 24, 2009

How do I set the font size property and special effect property in this code?

I was trying to answer a question on Experrt Exchange but Rory beat me to it and now I'm feeling frustrated that I can't get my solution to work.

Sub AddCombo()Dim rVals As Range, rCell As Range, lTop, lLef, lHeight, lWidth, lCount As LongSet rVals = ActiveSheet.Cells.SpecialCells(xlCellTypeAllValidation)lCount = 1For Each rCell In rVals    If rCell.Validation.Type = 3 Then        lTop = rCell.Top        lLeft = rCell.Left        lHeight = rCell.Rows.Height        lWidth = rCell.Columns.Width            With ActiveSheet.OLEObjects.Add(classtype:="Forms.ComboBox.1", Left:=lLeft, Top:=lTop, Width:=lWidth, Height:=lHeight)                .Name = "NewCombo" & lCount                .ListFillRange = rCell.Validation.Formula1                .LinkedCell = rCell.Address(0, 0)                '.SpecialEffect = fmSpecialEffectFlat //doesn't work //                '.FontSize = 14 //doesn't work //                '.Font.Size = 14 // doesn't work //            End With                        lCount = lCount + 1    End IfNext rCellEnd Sub

View 9 Replies View Related

Reference ActiveX ComboBox Value On Worksheet

Apr 10, 2008

How do I reference the value contained within a combobox using VBA?

I have tried the following:

ActiveSheet. OLEObjects("cmbSearchType").Object.Value
ActiveSheet.OLEObjects("cmbSearchType").Value
Sheets("mySheet").OLEObjects("cmbSearchType").Value
Sheets("mySheet").OLEObjects("cmbSearchType").Object.Value

I'm wanting to use the drop-down combo box as a simple way for the user to choose what type of search they wish to perform on the spreadsheet. The search algorithm chosen depends upon the current value show in the combo box.

I am using Excel 2007.

View 7 Replies View Related

Linking Sheets To ActiveX Combobox In Excel

Sep 13, 2012

I have a name list on sheet2, column A that will have names added to and removed from. Everytime this list is modified it sorts in ascending order and creates a new sheet named after the name added. These items are added to an ActiveX combo box on sheet1. I need to know how to link the item in the combo box to the corresponding sheet(ex: item: "Jim", sheet name: "Jim").

View 2 Replies View Related

Replacing Forms Control Combobox With ActiveX

Aug 13, 2014

Since Form Controls comboboxes don't allow font editing, I need to switch to ActiveX...

The combo box values come from the following cell range:

tbl_arrays!$I$3:$I$6

Those values are, from top to bottom: "select distance", "50 Miles", "100 Miles", "150 Miles".

The following macro is also assigned to the combobox:

[Code].....

I have two issues. The first is that the macro doesn't seem to be working. It is supposed to filter a list of cities within 50, 100 and 150 miles of a user input zip or city. The original Forms Control combo works but not ActiveX after I put the code in the change event:

[Code] .........

The second issue is that the last clicked value in the ActiveX comboBox replaces the top one.

Ex: from top to bottom, the combobox should display:

[Code] ........

but if the user clicks "100 Miles", the combobox is then going to display

[Code] ......

If the user then select "50 Miles", the box displays:

[Code] ........

View 4 Replies View Related

Copy And Paste To Worksheet Using Combobox (ActiveX)

Jan 22, 2009

I managed to put the names of my other worksheets into some comboboxes in the main worksheet by using this ....

View 12 Replies View Related

ActiveX Combobox With Dynamic Linked Cell?

Feb 4, 2012

I have a golf teetime reservation spreadsheet. For each tee time there can be up to four players names so I use 4 columns. Times are listed in rows every 10 minutes beginning 6am until 5pm for a total of 66 rows per day. I have a member/customer list that I have on a separate sheet that I've named. I am using the ActiveX combo box next to each possible entry (so 4 columns times 66 rows = 264 combo boxes). It's a little slow and takes a long time to open. I like the ActiveX combo box because it allows me to define the box format and display and it allows search/read/write capability. The idea is the customer calls, I ask what time they want and we arrive upon an available time. I ask for a last name, I click the combo box, type the first letter of the first name and then scroll if necessary to the name and click it to add the name to the time/player cell. If no name in my list we simply type it in and I'll capture it next time I refresh my customer list.

way to dynamically define the linkedcell in the properties so that instead of 264 combo boxes, I might have one combo box that I can click on and then direct my selection to the cell I want it to go into.

View 5 Replies View Related

Activex Combobox Change Font Size - VBA

Sep 13, 2012

I am trying to change the font size on my combo box using VBA.

I create the combobox dynamically, so need to be able to change the font too.

This is how I create the combobox, however the .Font.Size = 10 does not work and the default font size is 11.

Code:
With ActiveSheet .OLEObjects.Add(ClassType:="Forms.ComboBox.1", Link:=False, _
DisplayAsIcon:=False, Left:=159.75, Top:=80.25, Width:=75.75, Height:=19.5) _
.Font.Size = 10
.Name = "cmbBaseD"
.OLEObjects("cmbBaseD").ListFillRange = "DynRng"
End With

View 2 Replies View Related

Data Validation With ActiveX ComboBox With VB Code

Sep 19, 2013

I found a code on [URL] that claims that it will do what I want to achieve. I tried it but it is not working for me. Here is the code

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
Dim str As String

[Code]....

How to verify that this code is a working code and not just bogus one?

View 1 Replies View Related

OleObject ActiveX ComboBox Event Procedures

May 23, 2009

I've searched the web and OzGrid all day, and still have this question: what is the equivalent for .OnAction when using a ComboBox as shown in the code below. Everything else works as desired.

Loopcntr = 1

Set xyz = ActiveSheet. OLEObjects.Add(ClassType:="Forms.ComboBox.1", Link:=False, DisplayAsIcon:=False, _
Left:=Target.Left, Top:=Target.Top, Width:=Target.Width, Height:=Target.Height)

'''??? xyz.OnAction = "TDListing"
xyz.Object.BackColor = RGB(204, 255, 204)

Do While Loopcntr <= TaskListArraySizeHolder
DDholdName = TaskListArray(Loopcntr)
xyz.Object.AddItem DDholdName
Loopcntr = Loopcntr + 1
Loop

View 5 Replies View Related

ComboBox Not Populating

Jun 1, 2007

I have a combobox that is not populating correctly. The design of it uses an existing list (which changes every month) to populate the contents of the combobox. I want the user to be able to select a location from the list if it is already on the worksheet, rather than having to key in the location name for every single record. This Sub worked just fine and dandy for me until I deployed the workbook to the end user. Then this particular combobox decided not to work.

I have been over this code many, many times and I am almost positive that it's just a matter of my not being able to see the obvious. Perhaps another set of eyes looking at the code will be able to see what I can not.

Sub get_Locations()
Dim allCells As Range, Cell As Range
Dim noDupes As New Collection

Sheets("Main").Select
' get the first from last row #--the last row is a row of record counts and sums.
endRange = ActiveSheet.UsedRange.Rows.Count - 1

ComboBox1.Clear ' This will clear the combobox.
If endRange 65536 Then ' If the row number is not the end of the worksheet, _
there must be something already on the worksheet, so build the list.
On Error Resume Next
' Get unique values in range by checking each cell in range.
For Each Cell In Range("D12:D" & endRange)
noDupes.Add Cell.Value, CStr(Cell.Value)
Next Cell
On Error GoTo 0

' Sort the collection alphabetically within the combobox
For i = 1 To noDupes.Count - 1
For j = i + 1 To noDupes.Count
If noDupes(i) > noDupes(j) Then
Swap1 = noDupes(i)
Swap2 = noDupes(j)
noDupes.Add Swap1, before:=j
noDupes.Add Swap2, before:=i
noDupes.Remove i + 1
noDupes.Remove j + 1
End If
Next j
Next i

' Add items to combobox in their new alphabetical order.
itemIndex = 0
For Each Item In noDupes
UserForm2.ComboBox1.AddItem Item, itemIndex
itemIndex = itemIndex + 1
Next Item
Else ' otherwise there's no list to populate and the default row is 12
endRange = 12
Range("A12").Select
End If
End Sub

And just for the record, all object references (cell ranges, comboBox, etc.) are valid and correctly named, so I know it's not there. I also recognize that I have overspecified things by using "UserForm2", but I have done that in the hopes of finding the problem. And the code does execute at the proper times, populating "noDupes" correctly. The problem seems to occur near the end, in the block where noDupes is added to ComboBox1.

View 9 Replies View Related

Populating Combobox

Jul 3, 2006

I have a spreadsheet with loads of different columns on it, I am using a userform to control the spreadsheet. I have one form that allows me to add data to the spreadsheet and another that allows me to search it.

If one of my colums was a list of "counties" what I want to do is to have a combo box that displays all the counties listed so I can pick a specific one and and search it.

This I can do, the problem arises if a new county is added to the spreadsheet it will not be displayed in the combobox because I am using the additem "....." function to populate the box.

View 6 Replies View Related

ActiveX Combobox Date Format And List Index

Mar 30, 2014

I have an activeX combo box with dates in the following quarterly format (dec-14, march-15, july-15 etc), with the following code:

[Code] .....

However' while each code works fine standalone, the two codes wont work together - and the listindex reverts back to 0.

View 3 Replies View Related

Excel 2007 :: ActiveX Combobox And Shared Workbook

Jul 15, 2014

I have a workbook with a combo box.

ActiveX control? (=EMBED("Forms.ComboBox.1","") They are filled using named ranges on another worksheet and work fine. The problem happens when I share the workbook the combo boxes become completely non-functional. They don't even drop down when clicked.

View 2 Replies View Related

Populating Combobox From Different Sheet?

Nov 6, 2012

I have an ActiveX Combo box - and Im trying to fill from a 2nd sheet (same workbook). I can get the box to work if the data is on the same sheet but what to I put in the ListFillRange to get it to populate from another sheet ?

View 2 Replies View Related

Populating Combobox In A Form

Feb 27, 2014

I have two types of lists that has to be populated into comboboxes. First type is in a column with a header - lets say A1:A20. For them I`m using a following script:

Code:
For Each cell In ThisWorkbook.Sheets("NACE").Columns(1). _
Resize(Rows.Count - 1).Offset(1). _
SpecialCells(xlCellTypeConstants)
UF1.industry.AddItem CStr(cell.Value)
Next cell

With them all is fine until I need to start for example from row 26. (lets say range to populate is T26:T32) Then I`m lost. changing Offset(1) to Offset(26) doesn't work and I`m getting an error. That however can be handled with a workaround - creating another list that starts from the top. So I gave up on solving that. I need to populate a list from a range that is a row - B5:B20

I've adjusted the script to:

Code:
For Each cell In ThisWorkbook.Sheets("prod").Rows(5). _
Resize(, Columns.Count - 1).Offset(, 1). _
SpecialCells(xlCellTypeConstants)
UF1.PS.AddItem CStr(cell.Value)
Next cell

Because of some strange reason the script doesn`t see the number 1 in cell B5 and unless there are some more numbers in the following cells, it gives the "no cells found error".

View 9 Replies View Related

Populating A Combobox Manually

Aug 1, 2006

I'm sure there is an extremely simple answer to this question, but I can't seem to find it anywhere.

I am adding a combobox to a userform using the controls toolbox. How can I populate the combobox without a macro?

I do not want to add extra code to the UserForm_Initialize() event because this would just add clutter (I have seen numerous examples using .AddItem)

I would like to just change the combobox by hand.

View 9 Replies View Related

Combobox Not Populating Correctly

Sep 12, 2006

I have a userform with a combo box that is populated from a list in a sheet called Clients. The userform is in the same workbook as the Clients sheet. This workbook called "Client List.xls" and is set to be hidden from view. I've created a menu bar icon that loads the "Client List.xls" workbook, and on open runs the initialize procedure. The problem seems to be caused by the "Clients List.xls" being not the active workbook. Is this the case? Is there a way around it? If I unhide the workbook and make it the active workbook, the code works great.

Private Sub UserForm_Initialize()
Dim rngClients As Range
Dim wsSheet As Worksheet
Set wsSheet = Workbooks("Client List.xls").Sheets("Clients")
With wsSheet
.Range("a65536").End(xlUp).Select
.Range(Selection, "A1").Select
End With
Set rngClients = Selection
With cmbClients
.RowSource = rngClients.Address
.ListIndex = 0
End With

View 3 Replies View Related

Combobox - Populating From Another Sheet

Mar 1, 2007

I am trying to populate a combobox located in sheet1 with data from sheet2.

View 3 Replies View Related

Have Output Cell Of ActiveX Combobox Link To Named Range?

Apr 22, 2013

=AVERAGEIFS(MFI,DATE,">="&JanStart,DATE,"<="&JanEnd)

MFI is the named ranged that is referencing a column of data. This works, but I want to be able to change the MFI to a different named ranged.

So what I am trying to do is using an ActiveX Combo box so I can reference the named ranges that I have set, for example MFI, so each time a user chooses MFI or another named range, it will output to a linked cell (A1). Then the linked cell will be referenced into this forumla.

=AVERAGEIFS(A1,DATE,">="&JanStart,DATE,"<="&JanEnd)

Is it possible for A1 to be linked to the named range, so if the user choses MFI in the combo box, it will change all AverageIFS formulas to look at a different named range.

View 3 Replies View Related

Unable To Set Hidden Property Of Range Class ActiveX Combobox

Jul 30, 2013

Here is my code:

Code:
Private Sub ComboBox1_Change()
ActiveSheet.Rows("3:62").Hidden = False
Range("D1").Value = ComboBox1.Text
End Sub

I get a runtime error '1004' when I make my combo box selection. I don't have any security or password protection type stuff. The combo box is part of a more complicated spreadsheet and I don't want to switch to a data validation type drop down and I really want it to be activeX.

View 4 Replies View Related

VBA Populating Combobox From Unsorted List?

Jan 26, 2014

I have built a Userform that is for a Liquor Inventory. I would like to scan each bottle's UPC Code and pull it from a range list that is set up in (Combobox "UpcBarCodeBox"). That information is stored on a sheet "Liquor & Wine Inventory" in Column "A" (Unsorted). Column "B" is the name of the liquor which is also the column that everything is sorted in alphabetical order. What I would like to do is populate several textbox's that I have set up so that I can input missing data or data that needs to be updated. The problem is I would LOVE to keep the list sorted by Liquor Names (Column "B") and not by UPC Bar Codes (Column "A"). From my research I have found that Index and Match might be the way to go but I can't seem to get it to work right. Since I am still learning VBA, Some things still escape my grasp.

VB:

Private Sub UserForm_Initialize()
Me.UpcBarCodeBox.List = Worksheets("Liquor & Wine Inventory").Range("A5:A205").Value
With ComboBox2

[Code]....

View 9 Replies View Related

Populating Worksheet Column From Combobox

Sep 3, 2009

I have a userform with comboboxes and listboxes etc. The comboboxes have drop down lists which are populated from data in columns from a worksheet.

1.) During the execution of the userform, a value is selected from the combobox, which is place in a column on another worksheet. So far so good. If I select the same value again, nothing shows up in the row below the first selection. If I choose a different value it shows up. I have tried using different properties of the combobox but have not been able to get around this.

2.) I would like, when the excel file is opened that the userform is ready to go, ie enter data. I have tried putting the
Private Sub Workbook_Open()
UserForm1.Show
End Sub

in "ThisWorkbook" module but have had no success with it.

View 12 Replies View Related

Populating Directory Information Into Combobox?

Jan 24, 2013

I am having an issue with some code that I am using. I am using the code below to pull a list of folders within a specific directory. I run the code two different times, once on initialization and then again when the combobox values change. The code works well when it is run in initialization. However when the combobox is changed I wind up getting all of the folders listed in the combobox twice. I do not understand why this part of the code gets executed twice.

Here is the initialization code

Code:
Dim FileList, FilePath As Variant
mypath = "c:"
MyName = Dir(mypath, vbDirectory)

[Code].....

View 3 Replies View Related

VBA Populating Combobox From Unsorted List

Jan 25, 2014

I have built a Userform that is for a Liquor Inventory. I would like to scan each bottle's UPC Code and pull it from a range list that is set up in (Combobox "UpcCodeBox"). That information is stored on a sheet "Liquor & Wine Inventory" in Column "A" (Unsorted). Column "B" is the name of the liquor which is also the column that everything is sorted in alphabetical order. What I would like to do is populate several textbox's that I have set up so that I can input missing data or data that needs to be updated. The problem is I would LOVE to keep the list sorted by Liquor Names (Column "B") and not by UPC Bar Codes (Column "A"). From my research I have found that Index and Match might be the way to go but I can't seem to get it to work right.

Code:

Private Sub UserForm_Initialize()
Me.UpcBarCodeBox.List = Worksheets("Liquor & Wine Inventory").Range("A5:A205").Value
With ComboBox2
.AddItem "0"
.AddItem "1"
.AddItem "2"
.AddItem "3"

[Code]....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved