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
ADVERTISEMENT
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
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
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
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
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
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
Mar 1, 2007
I am trying to populate a combobox located in sheet1 with data from sheet2.
View 3 Replies
View Related
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
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
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
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
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
View Related
Mar 22, 2014
I have a Userform where I use a ComboBox to populate raw A from a worksheet.
I use this form to update new data that relates to the selected item in the ComboBox.
In that user form, when I select an item from the ComboBox, I idetifay it's raw and display the data from columns B,C...to I in text boxes on the Userform.
I then set the "Enable" property of the text boxes that has data to "False" so that field cannot be updated again.
What I do today is if all the fields where updated, a message box will say "All fields are full" and I clear the form.
Now I want to improve my selection by removing items from the ComboBox if all the "needing update" columns are field.
By this I want to filter out the items that where already updated before and only show the ones needing update.
Here is what I have, I need to change the UserForm_Initialize section so it will only show the rows needing update.
Code:
Private Sub UserForm_Initialize()
'Populate "Cards" Combobox.
Dim rngCards As Range
Dim ws As Worksheet
Set ws = Worksheets("Rejects")
[Code]..
View 7 Replies
View Related
Aug 10, 2009
Sheets("Sheet1").Shapes("ComboBox1").Select
Selection.ListFillRange = "='Sheet1'!$b$15:" & comborange & ""
where comborange = cell reference of the last cell in my range..
I have moved this combo box to a userform now and I'm trying to populate the box via one of the userforms triggers.. My problem is I can't figure out the syntax to select the combobox on the userform.. it doesn't seem to be handled the same way as when it was on the worksheet..
View 9 Replies
View Related
Dec 25, 2009
I have a problem involving two combo boxes in a user form.
I need to populate different “lists” to combo 2, based on a selection in combo 1.
I browsed through the forum but could not find any solution that made sense to me.
Here are the specifics:
Combo 1 (called Cbo_Act) is populated with a list based on a named range in one of the sheets. The range is named “activity” and holds 2 records (“Income” & “Expense”).
This list is loaded as part of the form initialization.
If the user select “Income”, I need combo 2 (called Cbo_Act_Type) to show a list of various income types (derived from a dynamic named range called “Income_type”) and if the user selects “Expense”, I need the same combo box (Cbo_Act_Type) to show a different list, specifically – a list of various expense types (derived from a dynamic named range called “Expense_type”).
I know that this should be with a Cbo_Act_Change () routine, but for the life of me, I can’t figure out how to do it.
View 9 Replies
View Related
Dec 30, 2011
I am trying to populate a combobox (CboMilestones) based on the project number that appears in CboProjNum. I need the values of certain columns to be added to CboMilestones. My spreadsheet is laid out in a paticular order based on a SQL upload that I will have to perform (1st column = project number, 2nd column = milestone 1, 3rd column = must be blank, 4th column = forecasted date, 5th column = actual date, 6th column = Milestone 2, 7th column = blank, 8th = forecasted date, 9th column = actual date....this repeats all the way to milestone 160) I need CboMilestone to populate with all the milestones on the row of selected project number, and then I need TxtADate and TxtFDate to display the dates of the selected milestone for the selected milestone.
Below is a pic of my spreadsheet and a pic of the code i have so far.
[IMG]
[URL]....; base64,
iVBORw0KGgoAAAANSUhEUgAABLMAAALMCAIAAACQRGcbAAAgAElEQVR4n
Oy9W3TcxoHnDdmxdXmi33TO98KTp9nZmbN9xp+
/1cwoy86MM0PvjGc7m3jNxLkgjpzh2DMxkmhsbsaJkChKuFnHgmM7pmzJhmXKbut
iQTIlU9dGJFmkJEaCKImiRFEERV0oiZ
FAXWzqWt9DNUEQKBSARjcbTf5/53d40NWFQgFEs+
vPAroF4SvHha8cF77eJ3y9T/jWOeHJ88KT56c9ddFW+Oc/
[Code]...
View 1 Replies
View Related
Jul 25, 2014
I'm trying to do some userform development with multiple dependent comboboxes, but I am having trouble populating the third and last combobox. First, I populate the 1st combobox on the userform initialization. I can get the first 2 comboboxes to populate correctly, but I can't seem to get the 3rd combobox to populate correctly.
The 3rd combobox takes the selection from the 2nd combobox and searches column "A" in the worksheet "Chassis Specs" and populates the 3rd combobox with data from column "B", there will be repeat items in column "A", but all those occurances should populate the 3rd combobox with the data from "B".
I am attaching my whole workbook.
Chassis Specs Info_Build_REV B.xlsm
View 14 Replies
View Related
May 5, 2009
Error Help.xls. An example is attached. If you open the attachment, you can see that I'd like to choose a date from the combobox and have the corresponding "date code" (that's what I'm calling it - it's for a different, more complex purpose) appear in the text box. For this to happen, I'm using the following
View 2 Replies
View Related
Oct 26, 2003
I am creating a Userform and one of the elements on it is a combobox where the user has to select their name. On the same Userform, I want to have a textbox (or listbox or another combo box if necessary) which will show the users default cost centre based on the initial combobox selection. I've tried doing this various ways, but I can't get the textbox to update when the combobox selection changes.
View 7 Replies
View Related
Dec 14, 2012
Below is the code for completing Sheet 1 using various comboxes on a User form. There are only 15 lines to which values can be entered on sheet 1. After the 15 lines have been completed, I would like to begin adding new data to sheet 2. However, I'm not really sure where to begin in terms of setting up a counter and then calling sheet 2 once the counter hits my limit. Sheet 2 is exactly identical to sheet 1 in layout and also has 15 lines.
Private Sub btnAdd_Click()
' This button will add medication info to excel worksheet
'RowCount will help find next empty row
[Code]....
View 1 Replies
View Related
Nov 16, 2012
I have a chart that have y-axis values normally between 0-50 but sometimes i get a peak with value 400 and then my chart becomes unclear because y-axis max value then goes up to 400.
Is it possible to set a roof here so max value on y-axis is e.g. 60 and values above that is visible as 60 then in the chart.
View 1 Replies
View Related
Jul 13, 2014
i am using excel to create 8 groups that does night shifts for 4 days then another group does it afterwards and so on. instead of putting the dates manually and adding 4 days after the start of each night shift, is there a way or a formula i could use to just make it easier so that i wont be able to just manually do the dates each year? i've put a screenshot copy of the excel file that i am working on.
View 1 Replies
View Related
Jan 21, 2009
Opening it manually the dates in column C are all consistently date numbers. i.e. using the =ISNUMBER() function to test them, they all return True
However when I include the VBA instruction:
View 7 Replies
View Related
Dec 19, 2007
when i try to create a formula on cell E7, D7 . and when i copy down the formula , it does not auto cal , i need to manually refresh , or save the file name , then the foumlar cal cell will updated.
Project (5) *ABCDE6Row Labels20062007060773M33789.7523454.52815.81252345.458AAEON*45419.32815.81252345.459ACCESSORIES112*2815.81252345.4510ASIS PCB638084102815.81252345.4511AUTENTO16392.1619578.272815.81252345.4512AXOR*600512815.81252345.4513BECKHOFF2652676.642784074.132815.81252345.4514BRAND - EXPERT222154612815.81252345.4515DANFOSS29780.3338514.022815.81252345.4516DELTA SERVO26245.366573.52815.81252345.4517ELMEX*15422.72815.81252345.4518GE FANUC1700346.271181053.752815.81252345.4519HAKKO1148010.51069760.112815.81252345.4520HANYOUNG103454543.52815.81252345.4521HENGSTLER362948.76298865.852815.81252345.4522HMS22267.598102815.81252345.45Spreadsheet FormulasCellFormulaD7=B7/12E7=C7/10D8=B8/12E8=C8/10D9=B9/12E9=C9/10D10=B10/12E10=C10/10D11=B11/12E11=C11/10D12=B12/12E12=C12/10D13=B13/12E13=C13/10D14=B14/12E14=C14/10D15=B15/12E15=C15/10D16=B16/12E16=C16/10D17=B17/12E17=C17/10D18=B18/12E18=C18/10D19=B19/12E19=C19/10D20=B20/12E20=C20/10D21=B21/12E21=C21/10D22=B22/12E22=C22/10 Excel tables to the web >> Excel Jeanie HTML 4
View 9 Replies
View Related
Feb 5, 2008
Running Windows XP; Excel 2003
I have a fairly simply macro.
It copies certain sheets out of a workbook (for a new workbook)
Unprotect the sheets in the new workbook
Deletes a particular cell on each sheet
Unhides a sheet
Sets all of the new worksheets to normal view
Protects the new sheets
Lets the user save and name the new workbook.
All is working fine Except it will not change the new workbook from Page Break View to Normal view.
The code I'm using = Sheets("name").Activate
Activewindow.View=xlNormal
Here's the strangest part. When I run the macro from a command button, the newly created workbook retains the page break view (as is in the original).
When I run the macro line by line via F8, IT WORKS JUST FINE
View 9 Replies
View Related
Feb 11, 2009
In one tab, I have a huge data set as follows:
account --- account(1) --- value
111111 --- b5 --- 123456
111111 --- a2 --- 32156
111111 --- c5 --- 31221
111111 --- e7 --- 1121312
222222 --- b5 --- 5464
222222 --- c1 --- 887895
333333 --- d4 --- 45454646
in another tab, I want to be able to manually input a value, in this case account, (1111 for example) and have it return all the values in account(1) (in this case b5, a2, c5, e7). Once I have that, I can do a vlookup to get the "value" which is what i need, but I just can't quite seem to get it to do the first part - I input account and it returns all account(1) values.
View 8 Replies
View Related
Mar 26, 2014
I have excel sheet it contains 200000 records.I want to delete records from 50000 to 200000.Is there any shortcut to delete data.
View 2 Replies
View Related
Jun 5, 2014
I would like to be able to put manually a formula in a specific cell (like a "requested date" cell) and then have a table that use this date for the headers and calculate +1 year for each columns.
For exemple:
=2012-01-01
=2013-01-01
=2014-01-01
=2015-01-01
requested date:
2012-01-01
Would you know a way to easily do it? when I try to do it manually (+365) it doesn't consider leap years. I thought about a =DATE formula but the requested date have to be manually entered...
View 3 Replies
View Related
Apr 10, 2007
I have 4 colums of data (A2:D5684) with the data sorted ascending by column A. I would like to delete the rows with duplicate information without having to manually look through the 5684 lines.
View 5 Replies
View Related