sswcharlie
05-24-2011, 08:59 PM
Hi everyone
I have done a user form awith a combobox and sever txt box and cmd buttons. Started with a code off net and changed to suit.
However I cannot get it to run . Have done the F8 etc, but as I am new to userforms I may have something minor wrong (or major!)
Can I send WB to someone to check for me ? or maybe upload to the group. A bit confidential and I would want it to come down asap for group. For starters this is the code and I am trying to run from the 'run' in vba.
Private Sub TextBox2_Change()
End Sub
Private Sub SelectCo_Change()
End Sub
Private Sub CombSelectCo_Change()
End Sub
Private Sub TxtProduct_Change()
End Sub
Private Sub UserForm_Click()
End Sub
frmSelectCo
Dim NotNow As Boolean
Private Sub cmdCancel_Click()
'Unload the userform
Unload Me
End Sub
Private Sub cmdEnter_Click()
NotNow = True
N = Application.Match(Me.cmbCombSelectCo.Value, Range("g12:m"), 0)
Cells(N, 1).Value = Me.TxtCoName.Text
Cells(N, 2).Value = Me.TxtProduct.Text
Cells(N, 3).Value = Me.TxtCountry.Text
'more codes to go in here
NotNow = False
End Sub
Private Sub cmbCombSelectCo_Change()
If NotNow Then Exit Sub
'vRange = ":g12:m" & Cells(Rows.Count, "g").End(xlUp).Row
vrange = "Contacts"
TxtCoName.Text = Application.VLookup(cmbItemName.Value, Sheets("Contacts").Range(vrange), 1, False)
TxtProduct.Text = Application.VLookup(cmbItemName.Value, Sheets("Contacts").Range(vrange), 2, False)
TxtCountry.Text = Application.VLookup(cmbItemName.Value, Sheets("Contacts").Range(vrange), 3, False)
'more codes to go in here
End Sub
Private Sub UserForm_Initialize()
'UserForm2.SelectCo.RowSource = "g12:m" & Cells(Rows.Count, "g").End(xlUp).Row
frmSelectCo.cmbSelectCo.RowSource = "Contacts"
End Sub
The userforms picks up the CompanyName data from a dynamic range called 'Contacts' which is in Contacts (sheet) starts at column g10 thru to column m
Vlookup puts the next three row details into the 3 boxes on user form, edit can then be done on data and using enter to update the Contacts dynamic range data.
All the txt boxes and cmb, and cmd buttons are all set up.
The Initialise code had the ' in front when I downloaded from athe net. Not sure if I should remove etc.
Some guidance would be appreciated.
Thanks
Charlie Harris:dunno or :bug:
Downunder
I have done a user form awith a combobox and sever txt box and cmd buttons. Started with a code off net and changed to suit.
However I cannot get it to run . Have done the F8 etc, but as I am new to userforms I may have something minor wrong (or major!)
Can I send WB to someone to check for me ? or maybe upload to the group. A bit confidential and I would want it to come down asap for group. For starters this is the code and I am trying to run from the 'run' in vba.
Private Sub TextBox2_Change()
End Sub
Private Sub SelectCo_Change()
End Sub
Private Sub CombSelectCo_Change()
End Sub
Private Sub TxtProduct_Change()
End Sub
Private Sub UserForm_Click()
End Sub
frmSelectCo
Dim NotNow As Boolean
Private Sub cmdCancel_Click()
'Unload the userform
Unload Me
End Sub
Private Sub cmdEnter_Click()
NotNow = True
N = Application.Match(Me.cmbCombSelectCo.Value, Range("g12:m"), 0)
Cells(N, 1).Value = Me.TxtCoName.Text
Cells(N, 2).Value = Me.TxtProduct.Text
Cells(N, 3).Value = Me.TxtCountry.Text
'more codes to go in here
NotNow = False
End Sub
Private Sub cmbCombSelectCo_Change()
If NotNow Then Exit Sub
'vRange = ":g12:m" & Cells(Rows.Count, "g").End(xlUp).Row
vrange = "Contacts"
TxtCoName.Text = Application.VLookup(cmbItemName.Value, Sheets("Contacts").Range(vrange), 1, False)
TxtProduct.Text = Application.VLookup(cmbItemName.Value, Sheets("Contacts").Range(vrange), 2, False)
TxtCountry.Text = Application.VLookup(cmbItemName.Value, Sheets("Contacts").Range(vrange), 3, False)
'more codes to go in here
End Sub
Private Sub UserForm_Initialize()
'UserForm2.SelectCo.RowSource = "g12:m" & Cells(Rows.Count, "g").End(xlUp).Row
frmSelectCo.cmbSelectCo.RowSource = "Contacts"
End Sub
The userforms picks up the CompanyName data from a dynamic range called 'Contacts' which is in Contacts (sheet) starts at column g10 thru to column m
Vlookup puts the next three row details into the 3 boxes on user form, edit can then be done on data and using enter to update the Contacts dynamic range data.
All the txt boxes and cmb, and cmd buttons are all set up.
The Initialise code had the ' in front when I downloaded from athe net. Not sure if I should remove etc.
Some guidance would be appreciated.
Thanks
Charlie Harris:dunno or :bug:
Downunder