Private Sub cmdEnter_Click()
Dim WS As Worksheet
Set WS = Worksheets("Data")
'find the end of column A
Dim x As Integer
x = 1
Do Until WS.Range("A" & x).Value = ""
x = x + 1
Loop
'last row having data = x-1
'Add data to database
WS.Range("A" & x).Value = txtJN.Value
WS.Range("B" & x).Value = txtCus.Value
WS.Range("C" & x).Value = txtSup.Value
WS.Range("D" & x).Value = txtPO.Value
WS.Range("E" & x).Value = txtDD.Value
ActiveWorkbook.Save
MsgBox "Data Saved Successfully"
'Clear text and combo boxes
txtJN.Value = ""
txtCus.Value = ""
txtSup.Value = ""
txtPO.Value = ""
txtDD.Value = ""
End Sub
Want to become an expert in VBA? So this is the right place for you. This blog mainly focus on teaching how to apply Visual Basic for Microsoft Excel. So improve the functionality of your excel workbooks with the aid of this blog. Also ask any questions you have regarding MS Excel and applying VBA. We are happy to assist you.