S
skippy
I currently have some data in one sheet that i want to paste to anothe
sheet programmatically. I can copy the data from the original sheet bu
i am having problems finding the next free cell to paste after i hav
done the original paste to Cell A2.
Any help would be greatly appreciated.
Thanks.
See Section denoted by ~~~~~~~~~~~
Sub CopyBuysAndSells()
Columns("A:M").Select
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending
Key2:=Range("D1") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1
MatchCase:= _
False, Orientation:=xlTopToBottom
Range("D2").Select
Do Until ActiveCell = ""
'' check value of active cell
If ActiveCell Like "Buy" Then
'' select entire row
ActiveCell.Rows("1:1").EntireRow.Select
''' copy row
Selection.Copy
Sheets("Buys").Select
'' First time we select the first space available in the range
Range("A2").Select
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''' need to iterate selection by 1 each time so not pasting ove
previous information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ActiveSheet.Paste
''' go back to orginial sheet
Sheets("VTAnalysis").Select
''' move down one row from last check
ActiveCell.Offset(1, 3).Select
Else
If ActiveCell Like "Sell" Then
'' check value of active cell
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Copy
Sheets("Sells").Select
Range("A2").Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Sheets("VTAnalysis").Select
ActiveCell.Offset(1, 3).Select
Else
'' move down to next selection
ActiveCell.Offset(1, 0).Select
End If
End If
Loop
Sheets("Summary").Select
Range("B1").Select
End Su
sheet programmatically. I can copy the data from the original sheet bu
i am having problems finding the next free cell to paste after i hav
done the original paste to Cell A2.
Any help would be greatly appreciated.
Thanks.
See Section denoted by ~~~~~~~~~~~
Sub CopyBuysAndSells()
Columns("A:M").Select
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending
Key2:=Range("D1") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1
MatchCase:= _
False, Orientation:=xlTopToBottom
Range("D2").Select
Do Until ActiveCell = ""
'' check value of active cell
If ActiveCell Like "Buy" Then
'' select entire row
ActiveCell.Rows("1:1").EntireRow.Select
''' copy row
Selection.Copy
Sheets("Buys").Select
'' First time we select the first space available in the range
Range("A2").Select
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''' need to iterate selection by 1 each time so not pasting ove
previous information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ActiveSheet.Paste
''' go back to orginial sheet
Sheets("VTAnalysis").Select
''' move down one row from last check
ActiveCell.Offset(1, 3).Select
Else
If ActiveCell Like "Sell" Then
'' check value of active cell
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Copy
Sheets("Sells").Select
Range("A2").Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Sheets("VTAnalysis").Select
ActiveCell.Offset(1, 3).Select
Else
'' move down to next selection
ActiveCell.Offset(1, 0).Select
End If
End If
Loop
Sheets("Summary").Select
Range("B1").Select
End Su