Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Copy/paste/sort

Sheet2 has data in cols A-F which are ordered in numeric order by colA. More
rows of data are added weekly.
I would like code which will copy all the data from Sheet2 and paste it to
Sheet8 (overwriting anything already there) and sort it in ascending order by
column C.
Rows 1 and 2 of both sheets are constants (headings) and therefore can be
omitted fron the copy/paste ranges.
Many thanks,

--
tia
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy/paste/sort


JockW;614328 Wrote:
Sheet2 has data in cols A-F which are ordered in numeric order by colA.
More
rows of data are added weekly.
I would like code which will copy all the data from Sheet2 and paste it
to
Sheet8 (overwriting anything already there) and sort it in ascending
order by
column C.
Rows 1 and 2 of both sheets are constants (headings) and therefore can
be
omitted fron the copy/paste ranges.
Many thanks,

--
tia



with Sheets("Sheet2")
LastRow = .Range("A" & rows.count).end(xlup).row
Set CopyRange = .rows("3:" & LastRow)
end with

with Sheets("Sheet8")
'clear sheet 8
.rows("3:" & Rows.count).delete

CopyRange.Copy _
Destination:=.rows(3)

LastRow = .Range("A" & rows.count).end(xlup).row
.rows("3:" & LastRow).sort _
header:=xlno, _
key1:=.range("A3"), _
order:=xlascending
end with


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

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Copy/paste/sort

Hi

Look at this:

Sub CopyPaste()
Dim TargetSh As Worksheet
Dim DestSh As Worksheet
Dim LastRow As Long

Set TargetSh = Worksheets("Sheet2")
Set DestSh = Worksheets("Sheet8")

LastRow = TargetSh.Range("A1:F" & Rows.Count) _
.SpecialCells(xlCellTypeLastCell).Row
TargetSh.Range("A3:F" & LastRow).Copy DestSh.Range("A3")

DestSh.Range("A2:F" & LastRow).Sort Key1:=DestSh.Range("C2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

Regards,
Per

"JockW" skrev i meddelelsen
...
Sheet2 has data in cols A-F which are ordered in numeric order by colA.
More
rows of data are added weekly.
I would like code which will copy all the data from Sheet2 and paste it to
Sheet8 (overwriting anything already there) and sort it in ascending order
by
column C.
Rows 1 and 2 of both sheets are constants (headings) and therefore can be
omitted fron the copy/paste ranges.
Many thanks,

--
tia


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
VBA copy paste sort refresh [email protected] Excel Programming 0 October 27th 06 05:09 PM
Sort, Copy, Paste..without Autofilter..Anyone??? jeffg Excel Worksheet Functions 1 October 19th 05 05:34 PM
vba to sort group copy paste to another sheet tango Excel Programming 1 November 5th 04 08:08 AM
vba to sort group copy paste to another sheet mango Excel Worksheet Functions 0 November 5th 04 04:27 AM


All times are GMT +1. The time now is 06:46 AM.

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

About Us

"It's about Microsoft Excel"