Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA copy paste sort refresh | Excel Programming | |||
Sort, Copy, Paste..without Autofilter..Anyone??? | Excel Worksheet Functions | |||
vba to sort group copy paste to another sheet | Excel Programming | |||
vba to sort group copy paste to another sheet | Excel Worksheet Functions |