Please help with Userform code. Thanks!

D

Damil4real

I have a userform that pulls data from a hidden sheet based on a combo
box choice. I’ll like to have a code to pick a number from the combo
box, change a data in one of about 100 or so textboxes, and be able to
click “update” and the data is updated in the hidden sheet.

I currently have the code below.

The code in between “--------------------code not
working------------------“ are not working, while the rest of the code
works fine. This is just the beginning of writing this code. As you
can see the code does not include all (about 100 textboxes/comboboxes/
checkboxes) that I need to make sure are updated when the “update” box
is clicked.

Can you help, please or is there a faster and easier way to accomplish
this?

Thanks!


Code:


Private Sub goButton_Click()
Dim lRelativeRow As Long
Dim strNamedRange As String

Dim ws As Worksheet
Dim strClient As String
Dim strEvent As String
Dim strProduct As String
Dim strTa As String
Dim strEff As String
Dim strAcct As String
Dim strPort As String
Dim strMirror As String
Dim strFmirror As String
Dim strOperation As String
Dim strType As String
Dim strClass As String
Dim strMany As String
Dim strGroup As String
Dim strUnitized As String
Dim strEmm As String
Dim strNumb As String
Dim strLead As String
Dim strSingle As String
Dim strFud As String

--------------------code not working------------------

Dim strFiscal As String
Dim strTaxLot As String
Dim strCost As String
Dim strTax As String
Dim strFixed As String
Dim strTreated As String
Dim strCall As String
Dim strAmor As String
Dim strOpr As String
Dim strOpt As String
--------------------code not working------------------



strClient = txtPart.Text
strEvent = TextBox13.Text
strProduct = TextBox1.Text
strTa = TextBox11.Text
strEff = TextBox10.Text
strAcct = TextBox9.Text
strPort = TextBox8.Text
strMirror = TextBox6.Text
strFmirror = TextBox7.Text
strOperation = cboProduct.Text
strType = cboType.Text
strClass = cboClasses.Text
strMany = TextBox68.Text
strGroup = cboGroup.Text
strUnitized = cboUnitized.Text
strEmm = cboEMM.Text
strNumb = TextBox18.Text
strLead = TextBox17.Text
strSingle = cboSingle.Text
strFud = TextBox19.Text

--------------------code not working------------------

strFiscal = txtFiscal.Text
strTaxLot = cboTaxLot.Text
strCost = cboCost.Text
strTax = cboTax.Text
strFixed = cboFixed.Text
strTreated = cboTreated.Text
strCall = cboCall.Text
strAmor = cboAmor.Text
strOpr = cboOpr.Text
strOpt = cboOpt.Text
--------------------code not working------------------


Set ws = ActiveWorkbook.Sheets("Funds Setup")

'Problem is here- for each worksheet is not working
'it is only update one worksheets
' The reason i want to use for each worksheets is- I might
have more than 2 worksheet

'On Error Resume Next


With ComboBox1
If .ListIndex > -1 Then
strNamedRange = .RowSource

'ListIndex starts at zero
lRelativeRow = .ListIndex + 1
'Fill with adjacent column to Combobox choice
ws.Range(strNamedRange)(lRelativeRow, 1) = strClient
ws.Range(strNamedRange)(lRelativeRow, 2) = strEvent
ws.Range(strNamedRange)(lRelativeRow, 3) = strProduct
ws.Range(strNamedRange)(lRelativeRow, 4) = strTa
ws.Range(strNamedRange)(lRelativeRow, 5) = strEff
ws.Range(strNamedRange)(lRelativeRow, 6) = strAcct
ws.Range(strNamedRange)(lRelativeRow, 7) = strPort
ws.Range(strNamedRange)(lRelativeRow, 8) = strMirror
ws.Range(strNamedRange)(lRelativeRow, 9) = strFmirror
ws.Range(strNamedRange)(lRelativeRow, 10) =
strOperation
ws.Range(strNamedRange)(lRelativeRow, 11) = strType
ws.Range(strNamedRange)(lRelativeRow, 12) = strClass
ws.Range(strNamedRange)(lRelativeRow, 13) = strMany
ws.Range(strNamedRange)(lRelativeRow, 14) = strGroup
ws.Range(strNamedRange)(lRelativeRow, 15) =
strUnitized
ws.Range(strNamedRange)(lRelativeRow, 16) = strEmm
ws.Range(strNamedRange)(lRelativeRow, 17) = strNumb
ws.Range(strNamedRange)(lRelativeRow, 18) = strLead
ws.Range(strNamedRange)(lRelativeRow, 19) = strSingle
ws.Range(strNamedRange)(lRelativeRow, 20) = strFud

--------------------code not working------------------

ws.Range(strNamedRange)(lRelativeRow, 21) = strFiscal
ws.Range(strNamedRange)(lRelativeRow, 22) = strTaxLot
ws.Range(strNamedRange)(lRelativeRow, 23) = strCost
ws.Range(strNamedRange)(lRelativeRow, 24) = strTax
ws.Range(strNamedRange)(lRelativeRow, 25) = strFixed
ws.Range(strNamedRange)(lRelativeRow, 26) = strTreated
ws.Range(strNamedRange)(lRelativeRow, 27) = strCall
ws.Range(strNamedRange)(lRelativeRow, 28) = strAmor
ws.Range(strNamedRange)(lRelativeRow, 29) = strOpr
ws.Range(strNamedRange)(lRelativeRow, 30) = strOpt

--------------------code not working------------------


End If
End With

optView = True

MsgBox "Database update!"



End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top