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:
For Each cell In ThisWorkbook.Sheets("NACE").Columns(1). _
Resize(Rows.Count - 1).Offset(1). _
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:
For Each cell In ThisWorkbook.Sheets("prod").Rows(5). _
Resize(, Columns.Count - 1).Offset(, 1). _
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".
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
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.
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.
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 ?
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
In lack of database experience, I am using a hidden Excel sheet for data and several other sheets with referenced data. I am populating the data sheet from an inputform and inserting new references on save. This works pretty good, but when the data has to be updated, I've currently used the before doubleclick event and hereby used the activecell for reference, but now the data is on a different sheet!
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.
Private Sub UserForm_Initialize() Me.UpcBarCodeBox.List = Worksheets("Liquor & Wine Inventory").Range("A5:A205").Value With ComboBox2
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.
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)
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.
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"
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
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..
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.
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.
I am trying to create a user form to edit some named ranges. The VBA user form designer is basically the same as Borland Delphi, so building the form itself was easy. What I can't figure out is how to populate the user form with the data from the spreadsheet.
I have a number of text boxes on the form with names like txtTier1Slots, txtTier1Ceiling, txtTier1Floor, etc up to 4.
I have a defined name that corresponds with each item, Tier1Slots, Tier1Ceiling, Tier1Floor, and so on. I'm using defined names because they're referenced in Conditional Formatting on one of the worksheets in my project. They don't exist as actual cells, just name references.
I want to get the form populated with those values. I've tried about twenty variations of the following code, using ThisWorkbook, Workbooks, Cells, Range, Name, and just about every cell reference method I can think of. I've so many different error messages, my head is spinning.
I have built a data entry form (Input tab) and have code populating a table (Table tab). Currently both are in the same book, but I would like to house them in separately.
What is the proper VBA syntax for this? Will both books need to be open in order to populate the table?
The 'real' data is hosted on sharepoint and is getting darn big. The result is problems opening the doc and looong save times. My thought was to have the secretaries doing data entry open a single sheet (Input Form) which will then populate the data in another sheet. I'm dreaming, aren't I...
I know Access would solve everything, but for cost reasons I am stuck with Excel.
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 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.
I've written a workbook that enables my workmates to enter sample information easily (workbook attached). What i need help on i cant get the combobox 's on the user form to pick up the related info in worksheet named "data" and insert it into the relavant coloumn in tab named "Results". I can get it to work without using combobox's and just typing the info into a textbox but i wanted to use combobox's.
Another thing i wanted to do was pick invidual results and send them the "Report" for printing. how would i do that.
I created a data entry form that contains a ComboBox. The ComboBox is based on a range that has three columns and many rows. The purpose is to have the user select an item from the first column, and the other two columns are automatically filled in on the table.
The form works and the data is transferred to the table as it should. The issue is that when you select the ComboBox, it displays the data from all three columns wrapped in two columns. Some of the data is repeated and it looks confusing. How do I have the drop down show only the data in the first column?
I have a userform called "Description_Form". I had a listbox on this which worked 100%. I then decided to replace the listbox with a combobox. I replaced the word listbox1 with combobox1 in teh code below and now I am getting an error message:
Run-time error '-2147352573 (800200003)':
Could not fine the specified object.
I have checked the name of the Combobox and it is definitely combobox1.
Sub PopulateListWithHorizontalRange(New_Dest As Variant) Dim x As Range Description_Form.ComboBox1.Clear For Each x In Range("S_DESTINATIONS").Cells 'here is where I get the error message Description_Form.ComboBox1.AddItem x.Value
I have a simple user form that has a combobox and 5 textboxes.
The combobox gets its row source from all the data in column A of the worksheet and the 5 textboxes will have decimal number inputted.
when commandbutton 1 is clicked I would like exel to find the value in the combobox on the worksheet and input the 5 textboxes in colums B-F. I'm sure it has something to do with "offset", but I can't quite figure it out.