Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
kevcar40
 
Posts: n/a
Default copy and paste with offset

Hi
I have a worksheet that contains rows of data i filter the blank rows
out leaving valid rows of data
what i want to do is copy the rows and paste them onto another
worksheet in the first blank row blank i know i need to use the offset
but is it posable to select a range(A2:AB25)
then paste this range onto the other worksheet

thanks



kevin

  #2   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi Kevin,

Try something like:

'=============
Sub Tester()
Dim WB As Workbook
Dim srcSH As Worksheet
Dim destSH As Worksheet
Dim srcRng As Range
Dim destRng As Range

Set WB = ActiveWorkbook '<<====== CHANGE
Set srcSH = WB.Sheets("Sheet1") '<<====== CHANGE
Set destSH = WB.Sheets("Sheet2") '<<====== CHANGE

Set destRng = destSH.Cells(Rows.Count, "A").End(xlUp)(2)

On Error Resume Next
Set srcRng = srcSH.Range("A2:AB25") '<<====== CHANGE
On Error GoTo 0

If Not srcRng Is Nothing Then
srcRng.Copy Destination:=destRng
End If

End Sub
'<<=============



---
Regards,
Norman


"kevcar40" wrote in message
ups.com...
Hi
I have a worksheet that contains rows of data i filter the blank rows
out leaving valid rows of data
what i want to do is copy the rows and paste them onto another
worksheet in the first blank row blank i know i need to use the offset
but is it posable to select a range(A2:AB25)
then paste this range onto the other worksheet

thanks



kevin



  #3   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi Kevin.

Set srcRng = srcSH.Range("A2:AB25") '<<====== CHANGE


was intended to be:

Set srcRng = srcSH.Range("A2:AB25").SpecialCells(xlVisible)

---
Regards,
Norman


"Norman Jones" wrote in message
...
Hi Kevin,

Try something like:

'=============
Sub Tester()
Dim WB As Workbook
Dim srcSH As Worksheet
Dim destSH As Worksheet
Dim srcRng As Range
Dim destRng As Range

Set WB = ActiveWorkbook '<<====== CHANGE
Set srcSH = WB.Sheets("Sheet1") '<<====== CHANGE
Set destSH = WB.Sheets("Sheet2") '<<====== CHANGE

Set destRng = destSH.Cells(Rows.Count, "A").End(xlUp)(2)

On Error Resume Next
Set srcRng = srcSH.Range("A2:AB25") '<<====== CHANGE
On Error GoTo 0

If Not srcRng Is Nothing Then
srcRng.Copy Destination:=destRng
End If

End Sub
'<<=============



---
Regards,
Norman



  #4   Report Post  
kevcar40
 
Posts: n/a
Default

thanks both

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Copy and Paste or Paste Special between Excel Workbooks wllee Excel Discussion (Misc queries) 5 April 29th 23 03:43 AM
Can't Copy and Paste foumulas? Emory Richter Excel Discussion (Misc queries) 2 October 1st 05 08:27 PM
copy paste nowfal Excel Discussion (Misc queries) 1 September 3rd 05 01:30 AM
I cannot paste from one workbook to another. Copy works, paste do. JimmyMc Excel Discussion (Misc queries) 1 June 10th 05 03:54 PM
Can't Copy and Paste between Excel 2003 Workbooks wllee Excel Discussion (Misc queries) 6 March 30th 05 02:59 PM


All times are GMT +1. The time now is 05:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"