J
Josh
I have 2 modules with a combo box in each that I would like to have
update automatically. Module 1: company names, Module 2: Company 1 & 2
address. Right now if I select company 1, I get company 1 address. If
I select Company 2, I still have company 1 addresses. If I go into view
code and run the form, I get company 1 and company 2 addresses.
Here is a basic form of what I had, I shrunk them to save space. (There
is more companies and addresses than 2.)
Module 1
Public Sub Combobox1_DropButtonClick()
Dim arrCompany(1 To 2)
arrCompany(1) = "Company 1"
arrCompany(2) = "Company 2"
Dim Entrycount As Long
For Entrycount = 1 To 2
Worksheets("Template").ComboBox1.AddItem
arrCompany(Entrycount)
Next
End Sub
Module 2
Public Sub ComboBox2_DropButtonClick()
'Company 1
If Worksheets("Template").ComboBox1.Value = "Company 1" Then
Dim arrNTC(1 To 2)
arrNTC(1) = "Company 1 Address 1"
arrNTC(2) = "Company 1 Address 2"
Dim Entrycount1 As Long
For Entrycount1 = 1 To 2
Worksheets("Template").ComboBox2.AddItem
arrNTC(Entrycount1)
Next
End If
'Company 2
If Worksheets("Template").ComboBox1.Value = "Company 2" Then
Dim arrSTC(3 To 4)
arrSTC(3) = "Company 2 Address 1"
arrSTC(4) = "Company 2 Address 2"
Dim entrycount2 As Long
For entrycount2 = 3 To 4
Worksheets("Template").ComboBox2.AddItem
arrSTC(entrycount2)
Next
End If
End Sub
Any help would be greatly appreciated, I am still quite new to VB.
Josh
update automatically. Module 1: company names, Module 2: Company 1 & 2
address. Right now if I select company 1, I get company 1 address. If
I select Company 2, I still have company 1 addresses. If I go into view
code and run the form, I get company 1 and company 2 addresses.
Here is a basic form of what I had, I shrunk them to save space. (There
is more companies and addresses than 2.)
Module 1
Public Sub Combobox1_DropButtonClick()
Dim arrCompany(1 To 2)
arrCompany(1) = "Company 1"
arrCompany(2) = "Company 2"
Dim Entrycount As Long
For Entrycount = 1 To 2
Worksheets("Template").ComboBox1.AddItem
arrCompany(Entrycount)
Next
End Sub
Module 2
Public Sub ComboBox2_DropButtonClick()
'Company 1
If Worksheets("Template").ComboBox1.Value = "Company 1" Then
Dim arrNTC(1 To 2)
arrNTC(1) = "Company 1 Address 1"
arrNTC(2) = "Company 1 Address 2"
Dim Entrycount1 As Long
For Entrycount1 = 1 To 2
Worksheets("Template").ComboBox2.AddItem
arrNTC(Entrycount1)
Next
End If
'Company 2
If Worksheets("Template").ComboBox1.Value = "Company 2" Then
Dim arrSTC(3 To 4)
arrSTC(3) = "Company 2 Address 1"
arrSTC(4) = "Company 2 Address 2"
Dim entrycount2 As Long
For entrycount2 = 3 To 4
Worksheets("Template").ComboBox2.AddItem
arrSTC(entrycount2)
Next
End If
End Sub
Any help would be greatly appreciated, I am still quite new to VB.
Josh