View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_4_] Bob Phillips[_4_] is offline
external usenet poster
 
Posts: 834
Default Copying a variable nuimber of rows

Try

With Activesheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
if LastRow 10 Then

FirstRow = LastRow - 9
Else

FirstRow = 1
EndIf

.Rows(FirstRow).Resize(LastRow - FirstRow).Copy
'then paste it wherever
End With

--

HTH

Bob

"FinMan@Sussex" wrote in message
...
I want to copy the most recent 10 rows (excluding the header row) from
worksheet A to worksheet B. My problem is how do I define a variable
number
of rows if there are fewer than 10 lines completed? I do not want to copy
any blank lines. I am fairly new to VBA and am struggling to work out the
code for this so any help will be gratefully appreciated. John