HELLO EVERYONE!! I built a Userform to enter information to a spreadsheet. The problem I am having is the info will not always go to the next available empty row. It comes back to the first row after any data is entered in the 3rd or forth column. Its driving me crazy and I new at writing codes. Here is what me code looks like:
Private Sub CmdOK_Click()
Dim LastRow As Object
Set LastRow = Sheet1.Range("a65536").End(xlUp)
LastRow.Offset(1, 0).Value = txtRA.Text
LastRow.Offset(1, 1).Value = txtJB.Text
LastRow.Offset(1, 2).Value = txtRH.Text
LastRow.Offset(1, 3).Value = txtGD.Text
LastRow.Offset(1, 4).Value = txtGK.Text
LastRow.Offset(1, 5).Value = txtAS.Text
LastRow.Offset(1, 6).Value = txtCJ.Text
LastRow.Offset(1, 7).Value = txtNQ1.Text
LastRow.Offset(1, 8).Value = txtNQ2.Text
LastRow.Offset(1, 9).Value = txtNQ3.Text
LastRow.Offset(1, 10).Value = txtA.Text
LastRow.Offset(1, 11).Value = txtCC.Text
LastRow.Offset(1, 12).Value = txtC.Text
LastRow.Offset(1, 13).Value = txtDTV.Text
LastRow.Offset(1, 14).Value = txtFE.Text
LastRow.Offset(1, 15).Value = txtNSTAR.Text
LastRow.Offset(1, 16).Value = txtNYSEG.Text
LastRow.Offset(1, 17).Value = txtCAP.Text
LastRow.Offset(1, 18).Value = txtPC.Text
LastRow.Offset(1, 19).Value = txtSCG.Text
LastRow.Offset(1, 20).Value = cboPROJECT.Text
LastRow.Offset(1, 21).Value = cboMONTH.Text
LastRow.Offset(1, 22).Value = txtNAME.Text
LastRow.Offset(1, 23).Value = txtMONITOR.Text
LastRow.Offset(1, 24).Value = cboINCIDENT.Text
LastRow.Offset(1, 25).Value = cboSUP.Text
LastRow.Offset(1, 26).Value = txtCORRECTED.Text
MsgBox "One record entered"
response = MsgBox("Do you want to enter another record?", _
vbYesNo)
If response = vbYes Then
txtRA.Text = ""
txtJB.Text = ""
txtRH.Text = ""
txtGD.Text = ""
txtGK.Text = ""
txtAS.Text = ""
txtCJ.Text = ""
txtNQ1.Text = ""
txtNQ2.Text = ""
txtNQ3.Text = ""
txtA.Text = ""
txtCC.Text = ""
txtC.Text = ""
txtDTV.Text = ""
txtFE.Text = ""
txtNSTAR.Text = ""
txtNYSEG.Text = ""
txtCAP.Text = ""
txtPC.Text = ""
txtSCG.Text = ""
cboPROJECT.Text = ""
cboMONTH.Text = ""
txtNAME.Text = ""
txtMONITOR.Text = ""
cboINCIDENT.Text = ""
cboSUP.Text = ""
txtCORRECTED.Text = ""
txtRA.SetFocus
Else
Unload Me
End If
End Sub
Can some please help!! You can also email me at chukujones234@msn.com
Private Sub CmdOK_Click()
Dim LastRow As Object
Set LastRow = Sheet1.Range("a65536").End(xlUp)
LastRow.Offset(1, 0).Value = txtRA.Text
LastRow.Offset(1, 1).Value = txtJB.Text
LastRow.Offset(1, 2).Value = txtRH.Text
LastRow.Offset(1, 3).Value = txtGD.Text
LastRow.Offset(1, 4).Value = txtGK.Text
LastRow.Offset(1, 5).Value = txtAS.Text
LastRow.Offset(1, 6).Value = txtCJ.Text
LastRow.Offset(1, 7).Value = txtNQ1.Text
LastRow.Offset(1, 8).Value = txtNQ2.Text
LastRow.Offset(1, 9).Value = txtNQ3.Text
LastRow.Offset(1, 10).Value = txtA.Text
LastRow.Offset(1, 11).Value = txtCC.Text
LastRow.Offset(1, 12).Value = txtC.Text
LastRow.Offset(1, 13).Value = txtDTV.Text
LastRow.Offset(1, 14).Value = txtFE.Text
LastRow.Offset(1, 15).Value = txtNSTAR.Text
LastRow.Offset(1, 16).Value = txtNYSEG.Text
LastRow.Offset(1, 17).Value = txtCAP.Text
LastRow.Offset(1, 18).Value = txtPC.Text
LastRow.Offset(1, 19).Value = txtSCG.Text
LastRow.Offset(1, 20).Value = cboPROJECT.Text
LastRow.Offset(1, 21).Value = cboMONTH.Text
LastRow.Offset(1, 22).Value = txtNAME.Text
LastRow.Offset(1, 23).Value = txtMONITOR.Text
LastRow.Offset(1, 24).Value = cboINCIDENT.Text
LastRow.Offset(1, 25).Value = cboSUP.Text
LastRow.Offset(1, 26).Value = txtCORRECTED.Text
MsgBox "One record entered"
response = MsgBox("Do you want to enter another record?", _
vbYesNo)
If response = vbYes Then
txtRA.Text = ""
txtJB.Text = ""
txtRH.Text = ""
txtGD.Text = ""
txtGK.Text = ""
txtAS.Text = ""
txtCJ.Text = ""
txtNQ1.Text = ""
txtNQ2.Text = ""
txtNQ3.Text = ""
txtA.Text = ""
txtCC.Text = ""
txtC.Text = ""
txtDTV.Text = ""
txtFE.Text = ""
txtNSTAR.Text = ""
txtNYSEG.Text = ""
txtCAP.Text = ""
txtPC.Text = ""
txtSCG.Text = ""
cboPROJECT.Text = ""
cboMONTH.Text = ""
txtNAME.Text = ""
txtMONITOR.Text = ""
cboINCIDENT.Text = ""
cboSUP.Text = ""
txtCORRECTED.Text = ""
txtRA.SetFocus
Else
Unload Me
End If
End Sub
Can some please help!! You can also email me at chukujones234@msn.com