copying multiple row to a new sheet
Hi
if I understood you you would like to copy columns B:H for each row in
whcih column B 0 "True". If this is correct try
Sub foo()
Dim rng As Range, cell As Range, rng1 As Range
Set rng = Range(Cells(2, "B"), Cells(Rows.Count, "B").End(xlUp))
Set rng1 = Nothing
For Each cell In rng
If cell.Value = "True" Then
If rng1 Is Nothing Then
Set rng1 = Range(cell, Cells(cell.row, "H"))
Else
Set rng1 = Union(rng1, Range(cell, Cells(cell.row, "H")))
End If
End If
Next
If Not rng1 Is Nothing Then
rng1.Copy Destination:=Worksheets("Sheet2").Range("B2")
End If
End Sub
--
Regards
Frank Kabel
Frankfurt, Germany
desperate wrote:
I tried using the code with this line:
rng1.Copy Destination:=Worksheets("Sheet2").Range("B2")
but it still doesn't do what I need it to do. I'm really stuck on
this. For the rows that are true, I need to move part of that row
over to another sheet, and I've gotten it to the point where it moves
the first row over, but then every other true in that column will not
move over. If anybody has any other suggestions it would be greatly
appreciated.
|