VBA Express Forum  




Go Back   VBA Express Forum > VBA Code & Other Help > Excel Help
     Feedback     
Register FAQ Members Arcade Knowledge Base Training Articles Consulting

Reply
 
Thread Tools Display Modes
Old 04-16-2012, 06:43 AM   #1
copyt

 
Joined: Mar 2012
Posts: 55
Kb Entries: 0
Articles: 0
Solved: VBA to assign positions for outputs

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.

VBA:
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
VBA tags courtesy of www.thecodenet.com

Local Time: 02:28 PM
Local Date: 05-24-2013

 
Reply With Quote Top
Old 04-16-2012, 07:09 AM   #2
xld
 
xld's Avatar
Distinguished Lord of VBAX

 
Joined: Apr 2005
Posts: 23,118
Kb Entries: 3
Articles: 2
Maybe

VBA:
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 lngPasteRow = 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
VBA tags courtesy of www.thecodenet.com


____________________________________________
Nihil simul inventum est et perfectum

Abusus non tollit usum

Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber

Local Time: 11:28 PM
Local Date: 05-24-2013
Location:

 
Reply With Quote Top
Old 04-16-2012, 07:30 AM   #3
copyt

 
Joined: Mar 2012
Posts: 55
Kb Entries: 0
Articles: 0
@ xld

Thank you very much

Local Time: 02:28 PM
Local Date: 05-24-2013

 
Reply With Quote Top
Old 04-16-2012, 09:13 AM   #4
copyt

 
Joined: Mar 2012
Posts: 55
Kb Entries: 0
Articles: 0
Could you please tell me one more thing? Can the output start from A4?

Local Time: 02:28 PM
Local Date: 05-24-2013

 
Reply With Quote Top
Old 04-16-2012, 11:27 AM   #5
xld
 
xld's Avatar
Distinguished Lord of VBAX

 
Joined: Apr 2005
Posts: 23,118
Kb Entries: 3
Articles: 2
VBA:
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 lngPasteRow = 3 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 lngPasteRow = lngPasteRow + 1 End If Sheets("sheet1").Range("A" & lngPasteRow) = ((Cells(i, 3) * Cells(i, 1)) - (Cells(i, 3) * 1.007825)) End If Next i End Sub
VBA tags courtesy of www.thecodenet.com


____________________________________________
Nihil simul inventum est et perfectum

Abusus non tollit usum

Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber

Local Time: 11:28 PM
Local Date: 05-24-2013
Location:

 
Reply With Quote Top
Old 04-18-2012, 02:54 AM   #6
copyt

 
Joined: Mar 2012
Posts: 55
Kb Entries: 0
Articles: 0
Thank you very much again

Local Time: 02:28 PM
Local Date: 05-24-2013

 
Reply With Quote Top
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 03:28 PM.


Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright © 2004 - 2012 VBA Express