#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Sort / Copy Macro

I have a spreadsheet in which the data changes daily (As far as number of
rows in each section)

Basically the data I want to sort is in columns A through D

I need a Macro to sort based on Column C from Largest Number to Smallest
Number, and delete any rows in which the number in Column C is less than but
not equal to 5.

Then copy what is in Column B for each row to another spreadsheet and
transpose from the column form to a single row.

The catch is the information that needs to be sorted is in the middle of a
bunch of other data, so, I would guess I could use some sort of code to match
the number "0" in column D for each row to sort and copy...

Hope this makes sense, thank you for your help!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Sort / Copy Macro

I used autofilter on columns C and D

Sub Macro1()
'
Set SourceSht = Sheets("Sheet1")
Set DestSht = Sheets("Sheet2")

With SourceSht
LastRow = .Range("C" & Rows.Count).End(xlUp).Row
.Rows("1:" & LastRow).Sort _
header:=xlNo, _
key1:=.Range("D1"), _
order1:=xlAscending, _
key2:=.Range("C1"), _
order2:=xlAscending



.Range("C1:D" & LastRow).AutoFilter
.Range("C1:D" & LastRow).AutoFilter _
Field:=1, _
Criteria1:="=5"
.Range("C1:D" & LastRow).AutoFilter _
Field:=2, _
Criteria1:="=0"

Set CopyRange = .Range("B1:B" & LastRow) _
.SpecialCells(Type:=xlCellTypeVisible)
CopyRange.Copy
DestSht.Range("A1").PasteSpecial , _
Paste:=xlPasteValues, _
Transpose:=True
End With
End Sub


"GoodTrouble" wrote:

I have a spreadsheet in which the data changes daily (As far as number of
rows in each section)

Basically the data I want to sort is in columns A through D

I need a Macro to sort based on Column C from Largest Number to Smallest
Number, and delete any rows in which the number in Column C is less than but
not equal to 5.

Then copy what is in Column B for each row to another spreadsheet and
transpose from the column form to a single row.

The catch is the information that needs to be sorted is in the middle of a
bunch of other data, so, I would guess I could use some sort of code to match
the number "0" in column D for each row to sort and copy...

Hope this makes sense, thank you for your help!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Sort / Copy Macro

Thanks Joel, with a few modifications it works perfect! You saved me a lot of
hassle and time!

"Joel" wrote:

I used autofilter on columns C and D

Sub Macro1()
'
Set SourceSht = Sheets("Sheet1")
Set DestSht = Sheets("Sheet2")

With SourceSht
LastRow = .Range("C" & Rows.Count).End(xlUp).Row
.Rows("1:" & LastRow).Sort _
header:=xlNo, _
key1:=.Range("D1"), _
order1:=xlAscending, _
key2:=.Range("C1"), _
order2:=xlAscending



.Range("C1:D" & LastRow).AutoFilter
.Range("C1:D" & LastRow).AutoFilter _
Field:=1, _
Criteria1:="=5"
.Range("C1:D" & LastRow).AutoFilter _
Field:=2, _
Criteria1:="=0"

Set CopyRange = .Range("B1:B" & LastRow) _
.SpecialCells(Type:=xlCellTypeVisible)
CopyRange.Copy
DestSht.Range("A1").PasteSpecial , _
Paste:=xlPasteValues, _
Transpose:=True
End With
End Sub


"GoodTrouble" wrote:

I have a spreadsheet in which the data changes daily (As far as number of
rows in each section)

Basically the data I want to sort is in columns A through D

I need a Macro to sort based on Column C from Largest Number to Smallest
Number, and delete any rows in which the number in Column C is less than but
not equal to 5.

Then copy what is in Column B for each row to another spreadsheet and
transpose from the column form to a single row.

The catch is the information that needs to be sorted is in the middle of a
bunch of other data, so, I would guess I could use some sort of code to match
the number "0" in column D for each row to sort and copy...

Hope this makes sense, thank you for your help!

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
Sort, Copy, and Paste macro, must execute twice to work B. CLAY Excel Discussion (Misc queries) 2 May 26th 09 10:07 PM
Need to sort a row of data and automatically copy in to another ro scidoc Excel Worksheet Functions 3 September 10th 07 02:54 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Using Macro to sort without clicking on macro button dd Excel Discussion (Misc queries) 3 May 3rd 07 06:00 PM


All times are GMT +1. The time now is 02:56 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"