Cjluke
03-21-2007, 12:41 PM
:banghead:
That is how I feel.
Ok, I have a list, and the last column on this list, if populated, indicates a certain type of investment security. I need to separate the rows that have this last column populated. I want to do this by cuttting & then pasting the row into another sheet within the workbook. Here is the simple macro that does what I need:
Sub IfThen()
If Range("M4") > 0 Then Range("A4:M4").Select
Selection.Cut
Sheets("JP Morgan - VRDNs").Select
Range("A4").Select
ActiveSheet.Paste
End Sub
How do I loop this code to effectively paste all of the rows that have the last column populated into a different sheet? Here is the code I am trying to work with:
Sub Test()
Dim MyColumn As Range
Dim MyRow As Range
Dim cell As Range
Set MyColumn = Sheets("JP Morgan - Municipal").Range(Cells(4, 13), Cells(500, 13))
For Each cell In MyColumn
If cell > 0 Then _
Set MyRow = cell.Row
Sheets("JP Morgan - Municipal").Range("a:m" & MyRow).Cut
Set MyRow = Sheets("JP Morgan - VRDNs").Cells(20000, 1).End(xlUp).Offset(1, 0)
Sheets("JP Morgan - VRDNs").Range("a" & MyRow).Paste
End If
Next cell
End Sub
Any help would be appreciated...
That is how I feel.
Ok, I have a list, and the last column on this list, if populated, indicates a certain type of investment security. I need to separate the rows that have this last column populated. I want to do this by cuttting & then pasting the row into another sheet within the workbook. Here is the simple macro that does what I need:
Sub IfThen()
If Range("M4") > 0 Then Range("A4:M4").Select
Selection.Cut
Sheets("JP Morgan - VRDNs").Select
Range("A4").Select
ActiveSheet.Paste
End Sub
How do I loop this code to effectively paste all of the rows that have the last column populated into a different sheet? Here is the code I am trying to work with:
Sub Test()
Dim MyColumn As Range
Dim MyRow As Range
Dim cell As Range
Set MyColumn = Sheets("JP Morgan - Municipal").Range(Cells(4, 13), Cells(500, 13))
For Each cell In MyColumn
If cell > 0 Then _
Set MyRow = cell.Row
Sheets("JP Morgan - Municipal").Range("a:m" & MyRow).Cut
Set MyRow = Sheets("JP Morgan - VRDNs").Cells(20000, 1).End(xlUp).Offset(1, 0)
Sheets("JP Morgan - VRDNs").Range("a" & MyRow).Paste
End If
Next cell
End Sub
Any help would be appreciated...