N
Novice
Hi, Thanks in advance. I am really a novice for VB. please don't laugh at my
silly codes. I am trying to copy info on "DataEntry" sheet to sheets "Data"
and "Comments". It works well pasting to "Data" but I got error msg like
"Runtime error 1004- application defined or object defined error" when
pasting to "Comments". Please see what's wrong with my code as below:
Private Sub Submit_Click()
‘Data Sheet
For DataRowNo = 2 To 100
If Worksheets("Data").Cells(DataRowNo, 17) = 1 Then
i = DataRowNo
Else
DataRowNo = DataRowNo + 1
End If
Next
Worksheets("Data").Cells(i, 1) = Worksheets("DataEntry").Cells(5, 3)
Worksheets("Data").Cells(i, 2) = Worksheets("DataEntry").Cells(6, 3)
‘Comment sheet
For DataRowNo2 = 2 To 30 '
If Worksheets("Comments").Cells(DataRowNo2, 7) = 1 Then
j = DataRowNo2
Else
DataRowNo2 = DataRowNo2 + 1
End If
Next
‘Error line (run time error 1004)
Worksheets("Comments").Cells(j, 3) = Worksheets("DataEntry").Cells(29, 21)
'Worksheets("Comments").Cells(j, 3) = Worksheets("DataEntry").Cells(37, 21)
End sub
silly codes. I am trying to copy info on "DataEntry" sheet to sheets "Data"
and "Comments". It works well pasting to "Data" but I got error msg like
"Runtime error 1004- application defined or object defined error" when
pasting to "Comments". Please see what's wrong with my code as below:
Private Sub Submit_Click()
‘Data Sheet
For DataRowNo = 2 To 100
If Worksheets("Data").Cells(DataRowNo, 17) = 1 Then
i = DataRowNo
Else
DataRowNo = DataRowNo + 1
End If
Next
Worksheets("Data").Cells(i, 1) = Worksheets("DataEntry").Cells(5, 3)
Worksheets("Data").Cells(i, 2) = Worksheets("DataEntry").Cells(6, 3)
‘Comment sheet
For DataRowNo2 = 2 To 30 '
If Worksheets("Comments").Cells(DataRowNo2, 7) = 1 Then
j = DataRowNo2
Else
DataRowNo2 = DataRowNo2 + 1
End If
Next
‘Error line (run time error 1004)
Worksheets("Comments").Cells(j, 3) = Worksheets("DataEntry").Cells(29, 21)
'Worksheets("Comments").Cells(j, 3) = Worksheets("DataEntry").Cells(37, 21)
End sub