save userform data to excel .... plz help

S_s_s

New Member
Joined
Sep 23, 2020
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
unable to save the userform dat to worksheet
VBA Code:
Private Sub CmdBtnSUBMIT_Click()

If VBA.IsNumeric(Me.TxtDISTCODE.Value) = False Then
MsgBox "Please enter DIST CODE", vbCritical
Else: Exit Sub
End If

If ComboBoxDEALER.Value = "" Then
MsgBox "Please select Dealer", vbCritical
Exit Sub
End If

If ComboBoxDIVISION.Value = "" Then
MsgBox "Please select Division", vbCritical
Exit Sub
End If

If ComboBoxCATEGORY.Value = "" Then
MsgBox "Please select Category", vbCritical
Exit Sub
End If

If ComboBoxSUBCATEGORY.Value = "" Then
MsgBox "Please select Sub-Category", vbCritical
Exit Sub
End If

If ComboBoxMODEL.Value = "" Then
MsgBox "Please select Model", vbCritical
Exit Sub
End If

If ComboBoxPRODUCTCODE.Value = "" Then
MsgBox "Please select Product-Code", vbCritical
Exit Sub
End If

If ComboBoxCOLOUR.Value = "" Then
MsgBox "Please select Colour", vbCritical
Exit Sub
End If


If VBA.IsNumeric(Me.TxtBILLEDQTY.Value) = False Then
MsgBox "Please enter BILLED QTY", vbCritical
Else: Exit Sub
End If

If VBA.IsNumeric(Me.TxtFREEQTY.Value) = FASLE Then
MsgBox "Please enter FREE QTY", vbCritical
Else: Exit Sub
End If

Dim erow As Long
Dim SD As Worksheet

Set SD = ThisWorkbook.Sheets("Sales Data")

erow = SD.Range("A" & Rows.Count).End(xlUp).Row

SD.Cells(erow + 1, "A").Value = TxtDATE.Text
SD.Cells(erow + 1, "B").Value = TxtDISTCODE.Text
SD.Cells(erow + 1, "C").Value = ComboBoxDEALER.Text
SD.Cells(erow + 1, "D").Value = ComboBoxDIVISION.Text
SD.Cells(erow + 1, "E").Value = ComboBoxCATEGORY.Text
SD.Cells(erow + 1, "F").Value = ComboBoxSUBCATEGORY.Text
SD.Cells(erow + 1, "G").Value = ComboBoxMODEL.Text
SD.Cells(erow + 1, "H").Value = ComboBoxPRODUCTCODE.Text
SD.Cells(erow + 1, "I").Value = ComboBoxCOLOUR.Text
SD.Cells(erow + 1, "J").Value = TxtBILLEDQTY.Text
SD.Cells(erow + 1, "K").Value = TxtFREEQTY.Text

End Sub




Private Sub ComboBoxCATEGORY_Change()
Dim SH As Worksheet
Set SH = ThisWorkbook.Sheets("TABLES")
Dim I As Integer
Me.ComboBoxSUBCATEGORY.Clear
For I = 2 To SH.Range("T" & Application.Rows.Count).End(xlUp).Row
If SH.Range("T" & I).Value = "SUB-CATEGORY" Then
If SH.Range("V" & I).Value = Me.ComboBoxCATEGORY.Value Then
Me.ComboBoxSUBCATEGORY.AddItem SH.Range("U" & I)
End If
End If
Next I

End Sub




Private Sub ComboBoxDIVISION_Change()
Dim SH As Worksheet
Set SH = ThisWorkbook.Sheets("TABLES")
Dim I As Integer
Me.ComboBoxCATEGORY.Clear
For I = 2 To SH.Range("T" & Application.Rows.Count).End(xlUp).Row
If SH.Range("T" & I).Value = "CATEGORY" Then
If SH.Range("V" & I).Value = Me.ComboBoxDIVISION.Value Then
Me.ComboBoxCATEGORY.AddItem SH.Range("U" & I)
End If
End If
Next I
End Sub



Private Sub ComboBoxMODEL_Change()
Dim SH As Worksheet
Set SH = ThisWorkbook.Sheets("TABLES")
Dim I As Integer
Me.ComboBoxPRODUCTCODE.Clear
For I = 2 To SH.Range("T" & Application.Rows.Count).End(xlUp).Row
If SH.Range("T" & I).Value = "PRODUCT-CODE" Then
If SH.Range("V" & I).Value = Me.ComboBoxMODEL.Value Then
Me.ComboBoxPRODUCTCODE.AddItem SH.Range("U" & I)
End If
End If
Next I
End Sub



Private Sub ComboBoxPRODUCTCODE_Change()
Dim SH As Worksheet
Set SH = ThisWorkbook.Sheets("TABLES")
Dim I As Integer
Me.ComboBoxCOLOUR.Clear
For I = 2 To SH.Range("T" & Application.Rows.Count).End(xlUp).Row
If SH.Range("T" & I).Value = "COLOUR" Then
If SH.Range("V" & I).Value = Me.ComboBoxPRODUCTCODE.Value Then
Me.ComboBoxCOLOUR.AddItem SH.Range("U" & I)
End If
End If
Next I
End Sub



Private Sub ComboBoxSUBCATEGORY_Change()
Dim SH As Worksheet
Set SH = ThisWorkbook.Sheets("TABLES")
Dim I As Integer
Me.ComboBoxMODEL.Clear
For I = 2 To SH.Range("T" & Application.Rows.Count).End(xlUp).Row
If SH.Range("T" & I).Value = "MODEL" Then
If SH.Range("V" & I).Value = Me.ComboBoxSUBCATEGORY.Value Then
Me.ComboBoxMODEL.AddItem SH.Range("U" & I)
End If
End If
Next I
End Sub



Private Sub TxtDISTCODE_Change()
Dim DD As Worksheet
Set DD = ThisWorkbook.Sheets("DEALER DATA")
Dim I As Integer
Me.ComboBoxDEALER.Clear
For I = 2 To DD.Range("A" & Application.Rows.Count).End(xlUp).Row
If DD.Range("A" & I).Value = TxtDISTCODE.Text Then
Me.ComboBoxDEALER.AddItem DD.Range("B" & I)
End If
Next I
End Sub



Private Sub UserFORM_ACTIVATE()
Dim SH As Worksheet
Set SH = ThisWorkbook.Sheets("TABLES")
Dim I As Integer
Me.ComboBoxDIVISION.Clear
For I = 2 To SH.Range("T" & Application.Rows.Count).End(xlUp).Row
If SH.Range("T" & I).Value = "DIVISION" Then
Me.ComboBoxDIVISION.AddItem SH.Range("U" & I)
End If
Next I
End Sub
 

Attachments

  • ad_dms no data.jpg
    ad_dms no data.jpg
    138.5 KB · Views: 8

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
It should be like this:

Rich (BB code):
  If VBA.IsNumeric(Me.TxtDISTCODE.Value) = False Then
    MsgBox "Please enter DIST CODE", vbCritical
    Exit Sub
  End If
  
  If ComboBoxDEALER.Value = "" Then
    MsgBox "Please select Dealer", vbCritical
    Exit Sub
  End If

  If ComboBoxDIVISION.Value = "" Then
    MsgBox "Please select Division", vbCritical
    Exit Sub
  End If

  If ComboBoxCATEGORY.Value = "" Then
    MsgBox "Please select Category", vbCritical
    Exit Sub
  End If

  If ComboBoxSUBCATEGORY.Value = "" Then
    MsgBox "Please select Sub-Category", vbCritical
    Exit Sub
  End If

  If ComboBoxMODEL.Value = "" Then
    MsgBox "Please select Model", vbCritical
    Exit Sub
  End If

  If ComboBoxPRODUCTCODE.Value = "" Then
    MsgBox "Please select Product-Code", vbCritical
    Exit Sub
  End If

  If ComboBoxCOLOUR.Value = "" Then
    MsgBox "Please select Colour", vbCritical
    Exit Sub
  End If

  If VBA.IsNumeric(Me.TxtBILLEDQTY.Value) = False Then
    MsgBox "Please enter BILLED QTY", vbCritical
    Exit Sub
  End If

  If VBA.IsNumeric(Me.TxtFREEQTY.Value) = FASLE Then
    MsgBox "Please enter FREE QTY", vbCritical
    Exit Sub
  End If
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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