PDA

View Full Version : Solved: Copy rows from one sheet to another.....



parttime_guy
05-20-2010, 10:46 PM
Two Flaps (A & B) - same formats.

If Cell below heading in Flap B is Blank - exit sub

If Cell below heading in Flap B has information - then copy all rows below heading in Flap B - into Flap A below last row available.

Problem - Cell below Heading in Flap A could be empty

Kindly help

Sub copy_rows()
If Sheets("Flap-B").Range("A3") = "" Then
Exit Sub
Else
' Do Something Here
Sheets("Flap-B").Select
Range("A65536").End(xlUp).Select

' Do Something Here
End If

End Sub

mbarron
05-21-2010, 05:22 AM
Does this do what you want?
Sub copy_rows()
Dim sA As Worksheet, sB As Worksheet, rCopy As Range
Set sA = Sheets("Flap-A")
Set sB = Sheets("Flap-B")

If sB.Range("A3") = "" Then
Exit Sub
Else
If sA.Range("A2") <> "" Then
Range(sB.Range("a3"), sB.Range("a3").End(xlToRight).End(xlDown)).Copy _
sA.Range("A" & Rows.Count).End(xlUp).Offset(1)
Else
Range(sB.Range("a2"), sB.Range("a3").End(xlToRight).End(xlDown)).Copy _
sA.Range("A" & Rows.Count).End(xlUp).Offset(1)
End If

End If
End Sub

parttime_guy
05-21-2010, 06:45 AM
Hey Barron,

Thx for the code - it perfect.

:beerchug:
Best regards

dubber
06-23-2010, 03:03 AM
can you modify this so that if FlabB is copied, it loos in futher sheets if there is data in a specific range?