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
I am using Office 2003. I found some code in Ozgrid and have been using for one application. I am building another application and having problems with the command buttons operating properly. I am attaching a sample worksheet. Just click on the "click here to search and add button" It will open a userform. You will see one side that has the following:
1st Pickup 2nd Pickup 3rd Pickup This populates itself by looking at the student row and that specific column. On the other side you have:
1 2 3 and Add Yes
This is where you put a yes and have it add to the proper column for that student. This is where I am having problems. I cannot seem to get it right.
The formula in question is: =N$4*VLOOKUP($B5,'BOM MATRIX'!$A$2:$AJ$500,INDIRECT("N3"),FALSE) which is currently keyed into cell N5
what I'm trying to do is to populate rows sideways so for example the formula in cell O5 should be: =O$4*VLOOKUP($B5,'BOM MATRIX'!$A$2:$AJ$500,INDIRECT("O3"),FALSE)
Problem is whenever I copypaste. The first part (N$4-> O$4) populates correctly while INDIRECT("N3") remains the same even though it should be INDIRECT("O3") instead
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.
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 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 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".
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
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.
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"
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
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")
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'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".
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 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.
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
how to use some form of the saveas dialog within excel without quotes appearing in the filename that is passed to the dialog.
For example:
ChDir ("J:TestFolder")
x = Application.GetSaveAsFilename("Test.xls", "Excel files (*.xl*),*.xl*", 1, "Custom Dialog Title")
The above code displays the saveas dialog form but has "Test.xls" surrounded by quotes. Normally, there would be no quotes around the specified filename.
Is there another way I can do this or will I just have to live with it?
A customer is eligible for a discount if the customer’s 2009 sales are greater than or equal to 200000 OR if the customers First Order was placed in 2012. " If its true it would be yes and if false no"
So far i have in the IF function =IF([@[2009 sales]]>= 200000 ,"Y","N")
How should i insert if the customers OR First Order was placed in 2012?
I have used the Excel program for a number of years to print out "Jukebox Title Strips" for my Jukebox. I have used the same "formula" for cell height, width, etc. during that time.
The outline of the title strips are preprinted and perforated on an 8.5" x 11" sheet. I recently tried to make some new strips and the printing does not line up correctly as it always had done in the past. Now, the titles are not high enough on the top portion of the sheet, and not low enough on the bottom portion of the sheet. So, it is not that I could just raise everything up or lower everything down to line up correctly... it now has to be changed in both directions. Of the 20 title strips on the sheet, the only ones that line up correctly are the two that are halfway down.
I thought that somehow the file had become corrupted, so I made a new template, but I still have the same problem.
Are there any suggestions of what I could do?
In the links below it shows an example of a Title Strip page.
I have three columns expressing death dates (date, month, year). The months and dates are finally sorting correctly within the same year, but I have it set to sort by year first.
The column starts off fine with 1860, goes up to 2013, then starts back at 1884 and goes back up to 2009. I can't find any difference between the two groups: there are some of the same years represented, there are blank month and date cells in both. I have a worksheet with birth dates that sorted fine; the only difference I can find is that birth dates only go up to 1997, but the column is formatted as General, so the turn of the century shouldn't be a problem.
I've tried highlighting the whole thing before sorting as well as selecting one cell as usual. I've also tried formatting the column as Text. I can't think of anything else.
I have a userform with several inputs which are validated, and should the input be invalid an ErrorProcedure is run. This basically displays a message telling the user what is wrong, and it should also be highlighting the text in the relevant field, but for some reason it is not doing that.