T
TJDeborah
I have a very simple form that inserts data into a simple spreadsheet
and it all works right now. However I want my command button that
inserts the data to initialize ( or clear all of the fields) once the
data has been place in the spreadsheet. I have a command button that
clears all of the fields but would really like it to on submit as well.
I just can't seem to get the logic correct. Here is my code for those
2 command buttons.
Private Sub cmdClearForm_Click()
Call UserForm_Initialize
End Sub
Private Sub cmdOK_Click()
ActiveWorkbook.Sheets("Data").Activate
Range("A1").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtdatee.Value
ActiveCell.Offset(0, 1) = txtjob.Value
ActiveCell.Offset(0, 2) = cboOperator.Value
ActiveCell.Offset(0, 3) = cboOperation.Value
ActiveCell.Offset(0, 4) = cboDescription.Value
ActiveCell.Offset(0, 5) = txtThickness.Value
ActiveCell.Offset(0, 6) = txtLength.Value
ActiveCell.Offset(0, 7) = txtQty.Value
ActiveCell.Offset(0, 8) = txtTime.Value
Range("A1").Select
End Sub
and it all works right now. However I want my command button that
inserts the data to initialize ( or clear all of the fields) once the
data has been place in the spreadsheet. I have a command button that
clears all of the fields but would really like it to on submit as well.
I just can't seem to get the logic correct. Here is my code for those
2 command buttons.
Private Sub cmdClearForm_Click()
Call UserForm_Initialize
End Sub
Private Sub cmdOK_Click()
ActiveWorkbook.Sheets("Data").Activate
Range("A1").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtdatee.Value
ActiveCell.Offset(0, 1) = txtjob.Value
ActiveCell.Offset(0, 2) = cboOperator.Value
ActiveCell.Offset(0, 3) = cboOperation.Value
ActiveCell.Offset(0, 4) = cboDescription.Value
ActiveCell.Offset(0, 5) = txtThickness.Value
ActiveCell.Offset(0, 6) = txtLength.Value
ActiveCell.Offset(0, 7) = txtQty.Value
ActiveCell.Offset(0, 8) = txtTime.Value
Range("A1").Select
End Sub