I hope some body can help me with this code
I have created a form and want to enter data into the form, the form needs to find the last row on a spreadsheet offset to the next row past data into several differents cells (all on the same row), clear the form ready for the next lot of data.
Private Sub CmdBtnEnterData_Click()
'Dim RowCount As 0
Dim RowCount As Long
Dim ctl As Control
'check user input
If Me.TxtBxDate.Value = "" Then
MsgBox "please enter the date"
Me.TxtBxDate.SetFocus
End If
If Me.TxtBxInfo.Value = "" Then
MsgBox "Please insert the details of the task as completed "
Me.TxtBxInfo.SetFocus
End If
If Me.CmboBxSite.Value = "" Then
MsgBox "Insert details of your location when the task was completed "
Me.CmboBxSite.SetFocus
End If
If Me.CmboBxProjTitle.Value = "" Then
MsgBox "Insert a project title for the task "
Me.CmboBxProjTitle.SetFocus
End If
If Me.CmboBxJob.Value = "" Then
MsgBox "what sort of work was this "
Me.CmboBxJob.SetFocus
End If
If Me.CmboBxServiceObj.Value = "" Then
MsgBox "The service objective this task falls under "
Me.CmboBxServiceObj.SetFocus
End If
'Write Data to the worksheet and clear the form ready for next input of data
'RowCount = Worksheets("Data").Range("A1").CurrentRegion.Rows.Count
'RowCount = 0("Data").Range("A1").CurrentRegion.Rows.Count
'RowCount = COUNTA(A:A)("Data").Range("A1").CurrentRegion.Rows.Count
'RowCount = ("Data").Range("A1").CurrentRegion.Rows.Count
'RowCount0 = Worksheets("Data").Range("A1").CurrentRegion.Rows.Count
RowCount = Worksheets("Data").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Data").Range("A1")
.Offset(RowCount, 0).Value = Me.TxtBxDate.Value
.Offset(RowCount, 1).Value = Me.TxtBxInfo.Value
.Offset(RowCount, 2).Value = Me.CmboBxSite.Value
.Offset(RowCount, 3).Value = Me.CmboBxProjTitle.Value
.Offset(RowCount, 4).Value = Me.CmboBxJob.Value
.Offset(RowCount, 5).Value = Me.CmboBxServiceObj.Value
.Offset(RowCount, 6).Value = Me.CmboBxObjectives.Value
.Offset(RowCount, 7).Value = Me.CmboBxActionSteps.Value
.Offset(RowCount, 8).Value = Me.CmboBxExpPerform.Value
.Offset(RowCount, 9).Value = Me.CmboBxExceedPer.Value
End With
'clear the form
For Each ctl In Me.Controls
If TypeName(ctl) = "textbox" Or TypeName(ctl) = "comboBox" Then ctl.Value = ""
'elself Typename (ctl) = "checkbox" Then ctl.Value = False
'elself Typename (ctl) = "checkbox" Then ctl.Value = False
'elself Typename (ctl) = "checkbox" Then ctl.Value = False
End If
Next ctl
End Sub
As you can see I have left in the bits I tried but didn't use
many thanks to any body that can help (as you can see I'm not an expert)
I have created a form and want to enter data into the form, the form needs to find the last row on a spreadsheet offset to the next row past data into several differents cells (all on the same row), clear the form ready for the next lot of data.
Private Sub CmdBtnEnterData_Click()
'Dim RowCount As 0
Dim RowCount As Long
Dim ctl As Control
'check user input
If Me.TxtBxDate.Value = "" Then
MsgBox "please enter the date"
Me.TxtBxDate.SetFocus
End If
If Me.TxtBxInfo.Value = "" Then
MsgBox "Please insert the details of the task as completed "
Me.TxtBxInfo.SetFocus
End If
If Me.CmboBxSite.Value = "" Then
MsgBox "Insert details of your location when the task was completed "
Me.CmboBxSite.SetFocus
End If
If Me.CmboBxProjTitle.Value = "" Then
MsgBox "Insert a project title for the task "
Me.CmboBxProjTitle.SetFocus
End If
If Me.CmboBxJob.Value = "" Then
MsgBox "what sort of work was this "
Me.CmboBxJob.SetFocus
End If
If Me.CmboBxServiceObj.Value = "" Then
MsgBox "The service objective this task falls under "
Me.CmboBxServiceObj.SetFocus
End If
'Write Data to the worksheet and clear the form ready for next input of data
'RowCount = Worksheets("Data").Range("A1").CurrentRegion.Rows.Count
'RowCount = 0("Data").Range("A1").CurrentRegion.Rows.Count
'RowCount = COUNTA(A:A)("Data").Range("A1").CurrentRegion.Rows.Count
'RowCount = ("Data").Range("A1").CurrentRegion.Rows.Count
'RowCount0 = Worksheets("Data").Range("A1").CurrentRegion.Rows.Count
RowCount = Worksheets("Data").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Data").Range("A1")
.Offset(RowCount, 0).Value = Me.TxtBxDate.Value
.Offset(RowCount, 1).Value = Me.TxtBxInfo.Value
.Offset(RowCount, 2).Value = Me.CmboBxSite.Value
.Offset(RowCount, 3).Value = Me.CmboBxProjTitle.Value
.Offset(RowCount, 4).Value = Me.CmboBxJob.Value
.Offset(RowCount, 5).Value = Me.CmboBxServiceObj.Value
.Offset(RowCount, 6).Value = Me.CmboBxObjectives.Value
.Offset(RowCount, 7).Value = Me.CmboBxActionSteps.Value
.Offset(RowCount, 8).Value = Me.CmboBxExpPerform.Value
.Offset(RowCount, 9).Value = Me.CmboBxExceedPer.Value
End With
'clear the form
For Each ctl In Me.Controls
If TypeName(ctl) = "textbox" Or TypeName(ctl) = "comboBox" Then ctl.Value = ""
'elself Typename (ctl) = "checkbox" Then ctl.Value = False
'elself Typename (ctl) = "checkbox" Then ctl.Value = False
'elself Typename (ctl) = "checkbox" Then ctl.Value = False
End If
Next ctl
End Sub
As you can see I have left in the bits I tried but didn't use
many thanks to any body that can help (as you can see I'm not an expert)