Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default HELP copy non-continous range

How do you copy non-continous range of cells and paste them into the
first cells of another new sheet for every row that is being picked up
by the IF statement?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default HELP copy non-continous range


Usually you would use Autofilter to get the required rows. Then us
specialcells method to copy the visible rows. And finally paste the
rows intot he new worksheet

Sub CopySelection()
'
Set OldSht = Sheets("Sheet1")
Set NewSht = Sheets("Sheet2")

With OldSht
LastRow = .Range("A" & Rows.Count).End(xlUp).Row

Columns("E:E").AutoFilter
Columns("E:E").AutoFilter Field:=1, Criteria1:="1"

Set SelectedRows = .Rows("2:" &
LastRow).SpecialCells(xlCellTypeVisible)
SelectedRows.Copy _
Destination:=NewSht.Rows(1).Paste
End With

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=148648

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default HELP copy non-continous range

Marina,

I think we need additional detail about what your trying to copy and to where.

Mike

"Marina" wrote:

How do you copy non-continous range of cells and paste them into the
first cells of another new sheet for every row that is being picked up
by the IF statement?
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default HELP copy non-continous range

There may be a *much* easier way than this, but it depends on what the
ranges of non-contiguous cells are. IF they are all made up of the same
columns, then you can just Copy them. Here are two examples...

Entire Rows
======================
Set Source = Range("1:4,8:13,20:20,22:25")
Set Destination = Worksheets("Sheet4").Range("A2")
With Source
.Copy Destination.Range("A4").Resize(.Rows.Count, .Columns.Count)
End With

Partial Rows
======================
Set Source = Range("A3:G5,A9:G16,A20:G30")
Set Destination = Worksheets("Sheet4").Range("A2")
With Source
.Copy Destination.Range("A4").Resize(.Rows.Count, .Columns.Count)
End With

Note: For both conditions, the Destination range is a single cell...
the first cell that will be copied to on the destination sheet.

--
Rick (MVP - Excel)


"joel" wrote in message
...

Usually you would use Autofilter to get the required rows. Then us
specialcells method to copy the visible rows. And finally paste the
rows intot he new worksheet

Sub CopySelection()
'
Set OldSht = Sheets("Sheet1")
Set NewSht = Sheets("Sheet2")

With OldSht
LastRow = .Range("A" & Rows.Count).End(xlUp).Row

Columns("E:E").AutoFilter
Columns("E:E").AutoFilter Field:=1, Criteria1:="1"

Set SelectedRows = .Rows("2:" &
LastRow).SpecialCells(xlCellTypeVisible)
SelectedRows.Copy _
Destination:=NewSht.Rows(1).Paste
End With

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=148648


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
Sum of continous cell Man Excel Worksheet Functions 3 July 14th 08 05:45 PM
continous assessment help with vba paul[_17_] Excel Programming 1 July 17th 07 06:44 PM
Compare 2 list and extract continous range Tamil Excel Programming 3 December 15th 06 09:15 AM
deleting rows in a non-continous range kiat Excel Programming 0 August 22nd 03 03:23 PM
deleting rows in a non-continous range Michael Tomasura Excel Programming 0 August 22nd 03 03:58 AM


All times are GMT +1. The time now is 11:18 PM.

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"