I have a userform whereby when I press a 'submit' button, the data contained with the textboxes on the form is written onto 2 different worksheets.
One worksheet (worksheet 1) has the data arranged across a row where as the other worksheet (worksheet 2) has the data arranged into a form template.
When the userform is used again, the data is written to the row below the last one on worksheet 1 but overwrites the data on worksheet 2.
Well......thats what I want it to do anyway. At the moment, the data in WS2 is being written a row below the last data! Just like WS1. I know the error lies somewhere in the code below and I'm sure it is the part that's highlighted in red. If I change the cell offset to (0,0) then the application hangs. I'm sure it has something to do with a loop.
Can someone help me please?
One worksheet (worksheet 1) has the data arranged across a row where as the other worksheet (worksheet 2) has the data arranged into a form template.
When the userform is used again, the data is written to the row below the last one on worksheet 1 but overwrites the data on worksheet 2.
Well......thats what I want it to do anyway. At the moment, the data in WS2 is being written a row below the last data! Just like WS1. I know the error lies somewhere in the code below and I'm sure it is the part that's highlighted in red. If I change the cell offset to (0,0) then the application hangs. I'm sure it has something to do with a loop.
Can someone help me please?
Code:
Private Sub cmdSubmit_Click()
ActiveWorkbook.Sheets("SIRs").Activate
Range("C6").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtSIRNo.Value
ActiveCell.Offset(0, -2) = cboStatus.Value
ActiveCell.Offset(0, 1) = txtDescription.Value
ActiveCell.Offset(0, 2) = txtSNOW.Value
ActiveCell.Offset(0, 3) = txtOriginator.Value
ActiveCell.Offset(0, 4) = txtItem.Value
ActiveCell.Offset(0, 5) = txtSerNo.Value
ActiveCell.Offset(0, 6) = txtPartNo.Value
ActiveCell.Offset(0, 7) = txtDate.Value
ActiveCell.Offset(0, 8) = txtStartTime.Value
ActiveCell.Offset(0, 10) = txtStopTime.Value
ActiveCell.Offset(0, 12) = txtConditions.Value
ActiveCell.Offset(0, 13) = txtDowntimeItem.Value
ActiveCell.Offset(0, 14) = txtDowntimeFPDS.Value
ActiveCell.Offset(0, 15) = txtReplacement.Value
ActiveCell.Offset(0, 16) = txtTask.Value
ActiveCell.Offset(0, 17) = txtError.Value
ActiveCell.Offset(0, 18) = txtMethod.Value
ActiveCell.Offset(0, 19) = txtAction.Value
ActiveCell.Offset(0, 20) = txtHandbookReference.Value
ActiveCell.Offset(0, 21) = txtProcedure.Value
ActiveCell.Offset(0, 22) = txtIssues.Value
ActiveCell.Offset(0, 23) = txtAttachments.Value
ActiveCell.Offset(0, 24) = txtRank.Value
ActiveCell.Offset(0, 25) = txtInformation.Value
ActiveCell.Offset(0, 26) = txtContinuation.Value
If opInoperable = True Then
ActiveCell.Offset(0, 9).Value = "Inoperable"
ElseIf opDegraded = True Then
ActiveCell.Offset(0, 9).Value = "Degraded"
Else
ActiveCell.Offset(0, 9).Value = "Unaffected"
End If
If opSparesYes = True Then
ActiveCell.Offset(0, 11).Value = "Yes"
Else
ActiveCell.Offset(0, 11).Value = "No"
End If
Range("C6").Select
ActiveWorkbook.Sheets("Template").Activate
Range("I4").Select
Do
[COLOR=red]If IsEmpty(ActiveCell) = False Then[/COLOR]
[COLOR=red]ActiveCell.Offset(1, 0).Select[/COLOR]
[COLOR=red]End If[/COLOR]
[COLOR=red]Loop Until IsEmpty(ActiveCell) = True[/COLOR]
ActiveCell.Value = txtSIRNo.Value
ActiveCell.Offset(15, -7) = txtDescription.Value
ActiveCell.Offset(0, 17) = txtOriginator.Value
ActiveCell.Offset(3, -7) = txtItem.Value
ActiveCell.Offset(3, 3) = txtSerNo.Value
ActiveCell.Offset(3, 13) = txtPartNo.Value
ActiveCell.Offset(6, -7) = txtDate.Value
ActiveCell.Offset(6, 3) = txtStartTime.Value
ActiveCell.Offset(9, -7) = txtStopTime.Value
ActiveCell.Offset(9, 13) = txtConditions.Value
ActiveCell.Offset(12, -7) = txtDowntimeItem.Value
ActiveCell.Offset(12, 3) = txtDowntimeFPDS.Value
ActiveCell.Offset(12, 13) = txtReplacement.Value
ActiveCell.Offset(19, -7) = txtTask.Value
ActiveCell.Offset(23, -7) = txtError.Value
ActiveCell.Offset(27, -7) = txtMethod.Value
ActiveCell.Offset(31, -7) = txtAction.Value
ActiveCell.Offset(35, -7) = txtHandbookReference.Value
ActiveCell.Offset(35, -7) = txtProcedure.Value
ActiveCell.Offset(39, -7) = txtIssues.Value
ActiveCell.Offset(43, -7) = txtAttachments.Value
ActiveCell.Offset(46, 3) = txtRank.Value
ActiveCell.Offset(46, -7) = txtOriginator.Value
ActiveCell.Offset(58, -7) = txtInformation.Value
ActiveCell.Offset(65, -7) = txtContinuation.Value
If opInoperable = True Then
ActiveCell.Offset(6, 13).Value = "Inoperable"
ElseIf opDegraded = True Then
ActiveCell.Offset(6, 13).Value = "Degraded"
Else
ActiveCell.Offset(6, 13).Value = "Unaffected"
End If
If opSparesYes = True Then
ActiveCell.Offset(9, 3).Value = "Yes"
Else
ActiveCell.Offset(9, 3).Value = "No"
End If
ActiveWorkbook.Sheets("SIRs").Activate
Range("C6").Select
Unload Me
End Sub