View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default copying multiple row to a new sheet

Hi
try changing the line
rng1.Range("B1:H1").Copy Destination:=Worksheets("Sheet2").Range("B2")

to
rng1.Copy Destination:=Worksheets("Sheet2").Range("B2")


--
Regards
Frank Kabel
Frankfurt, Germany

still stuck wrote:
I got my code working where it copies a row and moves it over to the
other sheet, but if I have multiple rows to move over it only moves
the first row that is true, but not the others. How can I get it to
move every row that is true over to a new sheet. Here's my code:

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 = cell
Else
Set rng1 = Union(rng1, cell)
End If
End If
Next
If Not rng1 Is Nothing Then
rng1.Range("B1:H1").Copy
Destination:=Worksheets("Sheet2").Range("B2") End If