useing another form to add value to combobox

rnzb

New Member
Joined
Oct 24, 2010
Messages
24
Hello,
i have a userform which include combox that i filled it's data from userform activate event , which get them from a range in a worksheet "items"

i have another form that add items to this worksheet "items"

i have a label in first userform to load the second user form
i use

form1.hide
form2.show (false)

now my question is whenever i exit form 2 i need the combobox in form 1 to update it's values
can anybody guide me
thank you in advance
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hello case Germany
thank you for the fast reply
please can you change the example to fit my needs

i am currently using the following code in order to fill the combobox and not
Set prov = Sheets("providers")
n = prov.Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
i = 0
For Each Item In prov.Range("B2:B" & n)
ComboBox1.AddItem Item, i
i = i + 1
Next

and not the following as you specified
ComboBox1.List = WorksheetFunction.Transpose _
(.Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp)))


while in the userform2 i use the following code in order to add to the range
h = ComboBox1 & " " & ComboBox2 & " " & " " & TextBox2
Set items = Sheets("items")

RowNum = 0
On Error Resume Next
RowNum = Application.WorksheetFunction.Match(CStr(h), cli.Range("B:B"), 0)
On Error Resume Next
If RowNum = 0 Then
k = items.Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count + 1
If k = 2 Then
idcounter = 0
Else
idcounter = items.Range("A" & k - 1).Value
End If
items.Range("a" & k) = idcounter + 1
items.Range("b" & k) = h
items.Range("c" & k) = ComboBox2
items.Range("d" & k) = ComboBox1
items.Range("e" & k) = TextBox2

TextBox2 = ""
ComboBox1.ListIndex = -1
ComboBox2.ListIndex = -1
Else
MsgBox (h & " is already exsits")
Exit Sub
End If
thank you in advance
 
Upvote 0
thank you sir
i fixed the problem
the trick was in your example which is

when i load userform2 i must call it userform2.show (false)
while when i return to userform1 i must call it userform1.show without (false)

thank you a lot
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top