Using Additem On A ComboBox From A Module
Aug 17, 2006
I am calling the following subroutine from a module (Mod_Global_Ini) for a combobox (ComBx_Supervisor) on a userform (Frm_JobCreate). why the .AddItem gives me an "Expected Function or Variable" error message?
Public Sub JobCreate_Initialize()
Frm_JobCreate.ComBx_Supervisor.AddItem = " "
Frm_JobCreate.ComBx_Supervisor.AddItem = "bp"
Frm_JobCreate.ComBx_Supervisor.AddItem = "cn"
Frm_JobCreate.ComBx_Supervisor.AddItem = "sm"
Frm_JobCreate.ComBx_Supervisor.AddItem = "jm"
End Sub
View 8 Replies
ADVERTISEMENT
Mar 27, 2009
After all the awesome macros I've obtained with the help of all of you, I now have over 30 macros, each in its own module. I have tried without success to re-name the modules with no luck. How is everyone organizing these?
View 2 Replies
View Related
Jan 24, 2013
Let's say i have 2 Modules on my VBA forms, is it possible to Copy all the Codes in Module 1 and Paste it to Module 2 by using a Command Button?
View 1 Replies
View Related
Jan 19, 2012
i got a question how i can make a msgbox in one module with 'Yes' linking to a different module.
such as: this is located in module2
Code:
If MsgBox("Do you want to activate module1?" & vbCr & _
"" _
, vbYesNo, "Choose") = vbNo Then Exit Sub
i want that vbYesNo different
No as in Exit Sub
yes as in activate Module1
View 5 Replies
View Related
Nov 26, 2004
I have a Listbox that has 2 columns
Using Additem how do I place data in the 1st then the 2nd column to create a list.
View 9 Replies
View Related
Jun 12, 2014
I am trying to use AddItem to add 3 columns in a listbox. (I know I can use Me.ListBox1.List=Array() ... but here I want to use AddItem)
From AddItem:
For multiple-column lists, use semicolons to delimit the strings for each column (for example, "1010;red;large" for a three-column list).
Here is my code but complete string is shown in 1 column where semicolon are visible. What am I doing wrong? I have also attached my example in a file.
AddItem_3Columns.xlsm
View 2 Replies
View Related
May 6, 2007
I have this part of code that populates my ListBox
With UserForm1.ListBox2
.AddItem ActiveCell.Offset(0, 7).Value
.AddItem ActiveCell.Offset(1, 7).Value
.AddItem ActiveCell.Offset(2, 7).Value
.AddItem ActiveCell.Offset(3, 7).Value
.AddItem ActiveCell.Offset(4, 7).Value
.AddItem ActiveCell.Offset(5, 7).Value
.AddItem ActiveCell.Offset(6, 7).Value
.AddItem ActiveCell.Offset(7, 7).Value
.AddItem ActiveCell.Offset(8, 7).Value
.AddItem ActiveCell.Offset(9, 7).Value
.AddItem ActiveCell.Offset(10, 7).Value
End With
It draws the Values (names) off of Sheet1 and ActiveCell is B26
Question one: Is there a better way of writing this and for it to stop adding to the ListBox once there is no Value in the Offset cell....
View 9 Replies
View Related
Dec 15, 2009
I have a userform (seen below) in which the user selects any number of ZIP Codes (right - ListBox2) after selecting a county/location (left - ListBox1.)
My dilema is that I need to somehow record the selections for EACH county/location, while making sure that when saving the selected ZIP's to the "Area Associations" sheet, I don't create duplicates. Of course any ZIP deselected needs to not be recorded to the sheet.
The "Area Associations" sheet is set up as follows:
[Any given row after row 1]
Column A = Area (Area is selected prior to the userform being displayed)
Column B - ??? = the selected ZIP's
The selected ZIP's do NOT have to be in any specific order, because I have a routine to search through the row looking for any instance of any particular ZIP Code.
FYI - Each ListBox is populated via .AddItem
View 9 Replies
View Related
Dec 12, 2006
I am trying to get a range from a worksheet and add it to my listbox1 on a form but i keep getting this error message.. Run=time error '1004': Method 'Range' of object '_worksheet' failed
Dim ws As Worksheet
Set ws = Worksheets("iSheet")
Dim ilastrow As Integer
ilastrow = ws.Range("A65536").End(xlUp).Row
Dim irow As Integer
irow = 0
For irow = 0 To ilastrow
If Trim(ws.Range("a" & irow).Value) <> "" Then
With ListBox1
.AddItem Trim(ws.Range("a" & irow).Value) & " - " & Trim(ws.Range("b" & irow))
End With
End If
Next
View 2 Replies
View Related
Jul 25, 2006
im using the following code to add to a combo box when a form loads
LstMullBkBx.AddItem "SCW059 - 50mm Box"
LstMullBkBx.AddItem "SCW060 - 75mm Box"
LstMullBkBx.AddItem "SCW061 - 100mm Box"
LstMullBkBx.AddItem "SCW062 - 125mm Box"
This seems to be a long way to do it. Is the a quicker way... as in
LstMullBkBx.AddItem "SCW059 - 50mm Box" & "SCW060 - 75mm Box" etc
I tried this but it adds them on the same line which is no good.
View 5 Replies
View Related
Mar 22, 2012
How I change the code below so that the ."AddItem" refers to a range within Sheet1?
For example .AddItem Worksheets("Sheet1").Range("O2:O20")
Code:
With ListBox1
.AddItem "January"
.AddItem "February"
.AddItem "March"
View 2 Replies
View Related
Dec 12, 2007
Works fine up to and including .List(i, 9) however when it bangs out with an error when it gets to .List(i, 10). Error Message reads: Run-Time Error '380': Could Not set the List property value.Invalid Property Value. If I Switch to using .column(10,i) I get the same error but for column instead
Dim cnt As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String, HASH As String
Dim D1 As String, D2 As String
Dim i As Long
HASH = Chr(35)
'*********TEMPINFO********
D1 = "12/3/2007" '*
D2 = "12/9/2007" '*
Agent = "Team_Stats" '*
i = 0 '*
'*************************
glob_DBpath = ThisWorkbook.Path & "databaseTS-Stats.mdb"
glob_sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & glob_DBpath & _
"; Jet OLEDB:Database Password=********;".......................
View 5 Replies
View Related
Oct 25, 2011
What i have at the moment is a module that contains code where i call a different module that i use as a procedure.
Module1
Code:
If Sheet1.Range("C4").Value < Sheet1.Range("A2").Value Then
If Sheet1.Range("K4") = "" Then
MsgBox "Please check 06:00 tasks not done yet!"
Cell = "Range(" & Chr(34) & "F4" & Chr(34) & ")"
If Sheet1.Range("C4") + 0.042 < Sheet1.Range("A2") Then
Run "EmailProSheet"
End If
End If
End If
EmailProSheet is what i call but now i want to use the variable "Cell" in the procedure as well?
Module3
Code:
MsgBox Cell
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
[Code]........
As it is now everything is working fine but does not return a value in "Cell" if the procedure is called. Is there another way?
View 5 Replies
View Related
Nov 28, 2008
I've written an Excel (using 2007, compatibility mode to 2003) app for our stock control. Basically it's a protected stock sheet which the user adds/removes stock via a form.
When the user runs the form the following code loops through the stock list header adding item names to a combo box. Problem is I get a run-time error if there's more than 60+ items but while the error always occurs, it happens at different places in additems.
Run-time error '-2147024809 (80070057)
Invalid argument.
In the code I've allowed a loop to 1000 items but in reality they'll be no more than 150.
View 11 Replies
View Related
Aug 4, 2006
I'm trying to fill a listbox use code. The code I have is the following:
listrow = Worksheets("DATA"). Range("A1"). CurrentRegion.rows.Count
Worksheets("DATA").Range("A1").Select
For i = 1 To listrow
Cells(i, 1).Value = CStr(Cells(i, 1))
Worksheets("BOM").Lbxitems.AddItem Sheets("DATA").Cells(i, 1)
Next i
It all worked fine, and now suddently it doesnt anymore.
I get the following error message:
Run-time error 2147352571(8002005).
View 9 Replies
View Related
Aug 18, 2004
I recieve an error :
Run-time error '50289':
Can't perform operation since the project is protected.
When i try and run my code.
The code does add parts to modules and workbook events, but I need the code to be protected.
View 9 Replies
View Related
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
Mar 30, 2014
I need to populate two combo boxes from excel sheet, the data will be like below:
Column A Column B
A 1
A 2
A 3
A 4
A 5
B 100
B 101
B 102
So from the above data, one combo box should hold unique values A & B.
On selecting a value from the 1st combo box A or B, respective values should be populated in 2nd combo box.
So the data should be like below:
If A is selected in the 1st combo box, then 2nd combo box should only show the values 1,2,3,4 & 5.
If B is selected in the 1st combo box, then 2nd combo box should only show the values 100,101 & 102.
Friends I need it in a macro and one important point is, this is dynamic and it is not static and the data can be more.
View 1 Replies
View Related
Dec 8, 2009
When I make a comboBox selection from the dropdown menu, the menu stays down until the last statement of the comboBox code is finished. How do I make the dropdown disappear immediately after the selection is made?
View 9 Replies
View Related
Jun 20, 2009
try and achive is when a user selects a item from the 1st Combobox the 2nd Combobox is the populated with the cell that is to the right of the selected item.
for Example if a user selects AAB from combobox1,, Combobox2 should populate with Belly.
Maby using combobox1_Exit for the excercise.
View 14 Replies
View Related
Sep 28, 2013
I created a UserForm then linked ComboBox1 to range A2:A, TextBox2 to range E2:E, and ComboBox3 to range M2:M of the same worksheet, named Sheet3. The row contents in Column A, Column E, and Column M are associated. Therefore, when the UserForm is active I want to be able to select a row from Column A in ComboBox1 and have the UserForm pull the contents from the same row of Column E into TextBox2, and Column M into ComboBox3. Here is what I have so far, but its not quite doing it.
Code:
Private Sub UserForm_Initialize()
Sheets("Sheet3").Activate
Dim ColARange As Range
[Code].....
View 2 Replies
View Related
Jun 12, 2006
I have a table, headers "FirstName" and "SurName".
Further a Userform with 2 Comboboxes "FirstName" and "SurName"
I'd like to choose the FirstName (say Jack) in the "FirstName" combobox, and based on that get the choice of the Surnames of all my Jacks in the "SurName" combobox.
Actually my sheet has much more fields and comboboxes, but i think my problem is just that I do not find a way to populate them dynamically.
View 9 Replies
View Related
Feb 8, 2008
How can i Loop through a combobox's values and compare to a string value and then set the listindex of the combobox to that value?
View 5 Replies
View Related
Nov 27, 2012
I have created a userform in which there are numerous Text and Combo boxes. In ComboBox 1 I have, in effect, a list of named ranges in a spreadsheet.
I want the RowSource for ComboBox 2 to equal the item selected (named range) in ComboBox 1.
VB:
Private Sub UserFormcriteria_Click()
Set ComboBox2.RowSource = ComboBox1.Value
End Sub
View 8 Replies
View Related
Jan 23, 2009
I want to fill two Combobox (cmb 2 and 3) dependent on what the user has chosen in a first ComboBox (cmb1).
The first combobox ist based on on the first sheet, and the second and third combobox shall be filled with values from other worksheet corresponding on combobox 1 selection.
I attached a xls to this post to explain better.
View 14 Replies
View Related
Dec 2, 2009
I have a userform with a combobox that has three items to choose from: Blue, Red, and Yellow. When a user selects one of those options, I would like another combobox to appear on my userform with a specific list for that option.
View 2 Replies
View Related
Apr 9, 2012
I'm trying to make a userform that has 2 combo boxes. I have just 3 columns right now.
Procedure GrpADA-QSI DescProcedure GrpAnesthesia And
Drugs9210-LOCAL ANESTH/NO SURGAnesthesia And DrugsAnesthesia And
Drugs9212-TRIGEM BLOCK ANESTHCrowns And BridgeAnesthesia And
Drugs9215-LOCAL ANESTHESIADenturesAnesthesia And
[Code] ........
I copied and pasted Column A into Column C and then removed duplicates. I named Column C 'ValList' and placed it in the RowSource for ComboBox1. What I now want is for ComboBox2 to populate based on my selection in ComboBox1. There are no duplicates in Column B. Duplicates are in Column A.
I also named Column A 'Proc_Grp' and Column B 'ADA_QSI_Desc'
For the properties in Combobox2, I left the RowSource empty. (that's correct right?) Because there's going to be a code that links Combobox2 to Combobox1... I think...
View 6 Replies
View Related
Apr 8, 2007
is it possible to perform calculation such as sum,multiply value of 2 combobox and get it shown at 3rd combobox/label at userform initialize stage?
View 9 Replies
View Related
Jun 9, 2006
I have a userform where I have 2 comboboxes. The first combobox shows the the first column (only 1 of each) and the second comboBox shows me the secondary list that correlates to the valuse in the first from column B. Now I have a text box that I am trying to get the value from column C depending on what I have in the first 2 comboboxes. What is the easiest way to do it? This is all in VB since it is a UserForm, and using Vlookup seems to be too many lines if I go that route. Is there a way to use Index and Match in VB where it would be more efficient? I attached just a sample of how the data would be layed out in the Excel sheet.
View 4 Replies
View Related
Dec 21, 2012
I have created an Excel Add-in to create the Text file. I want to create the text file through select sheet from userform.
View 9 Replies
View Related