copyt
04-16-2012, 06:43 AM
Hello all, I have a code to analyze my data according to a certain formular. The outputs will be added to Sheets1/Column A/last row. My problem is the outputs are only added to range A1. Can anybody suggest me a solution for this problem? Any help would be appreciated. :help
Sub Part03()
Application.ScreenUpdating = False
Worksheets("Precursor_ions").Activate
Dim finalrow As Long, _
i As Long
Dim lngPasteRow As Long
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To finalrow
If Not Cells(i, 3) = "" Then
If ((Cells(i, 3) * Cells(i, 1)) - (Cells(i, 3) * 1.007825)) > 0 Then
On Error Resume Next
lngPasteRow = Sheets("sheet1").Range("A").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
On Error GoTo 0
If lngPasteRow = 0 Then
lngPasteRow = 1
End If
Sheets("sheet1").Range("A" & lngPasteRow) = ((Cells(i, 3) * Cells(i, 1)) - (Cells(i, 3) * 1.007825))
End If
End If
Next i
End Sub
Sub Part03()
Application.ScreenUpdating = False
Worksheets("Precursor_ions").Activate
Dim finalrow As Long, _
i As Long
Dim lngPasteRow As Long
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To finalrow
If Not Cells(i, 3) = "" Then
If ((Cells(i, 3) * Cells(i, 1)) - (Cells(i, 3) * 1.007825)) > 0 Then
On Error Resume Next
lngPasteRow = Sheets("sheet1").Range("A").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
On Error GoTo 0
If lngPasteRow = 0 Then
lngPasteRow = 1
End If
Sheets("sheet1").Range("A" & lngPasteRow) = ((Cells(i, 3) * Cells(i, 1)) - (Cells(i, 3) * 1.007825))
End If
End If
Next i
End Sub