Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Microsoft Excel 2007 - VBA To Sort Table And Copy To Another Sheet

I have a table in Microsoft Excel 2007 (TableT - Range A1:D30 on Sheet1 ...
A1 to D1 are the Table Headers) that contains various information on Sheet1.
I would like to Sort TableT where all rows containing an \"X\" in column A
are shown. Then copy those rows and paste them on Sheet2 from A1:A30. Then I
want to sort TableT where all rows with a \"Y\" in column A are shown. Then
copy those rows and paste them on Sheet2 A30:A60. Is there VBA that I can use
to automate this? Thanks for your help.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Microsoft Excel 2007 - VBA To Sort Table And Copy To Another Sheet

I don't you want to "sort".

You want to "filter".

Record a macro whilst doing the filtering for \"X\" or \"Y\" and doing the
copy and paste


Gord Dibben MS Excel MVP

On Thu, 8 Oct 2009 07:04:03 -0700, Currently Challenged ... <Currently
Challenged wrote:

I have a table in Microsoft Excel 2007 (TableT - Range A1:D30 on Sheet1 ...
A1 to D1 are the Table Headers) that contains various information on Sheet1.
I would like to Sort TableT where all rows containing an \"X\" in column A
are shown. Then copy those rows and paste them on Sheet2 from A1:A30. Then I
want to sort TableT where all rows with a \"Y\" in column A are shown. Then
copy those rows and paste them on Sheet2 A30:A60. Is there VBA that I can use
to automate this? Thanks for your help.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Microsoft Excel 2007 - VBA To Sort Table And Copy To Another Sheet

Try the below macro

--If the entry is \"X\" in the code it is referred as double-double quotes
to represent a double quote...Try the below and feedback...


Sub MyMacro()
Dim lngRow As Long, lngRowX As Long, lngRowY As Long
lngRowX = 1: lngRowY = 31
For lngRow = 1 To 30
If Range("A" & lngRow) = "\""X\""" Then
Range("A" & lngRow).Resize(, 4).Copy _
Sheets("Sheet2").Range("A" & lngRowX)
lngRowX = lngRowX + 1
ElseIf Range("A" & lngRow) = "\""Y\""" Then
Range("A" & lngRow).Resize(, 4).Copy _
Sheets("Sheet2").Range("A" & lngRowY)
lngRowY = lngRowY + 1
End If
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Currently Challenged ..." wrote:

I have a table in Microsoft Excel 2007 (TableT - Range A1:D30 on Sheet1 ...
A1 to D1 are the Table Headers) that contains various information on Sheet1.
I would like to Sort TableT where all rows containing an \"X\" in column A
are shown. Then copy those rows and paste them on Sheet2 from A1:A30. Then I
want to sort TableT where all rows with a \"Y\" in column A are shown. Then
copy those rows and paste them on Sheet2 A30:A60. Is there VBA that I can use
to automate this? Thanks 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 Rows Pivot Table-Excel 2007 Alexandra Ramos Excel Discussion (Misc queries) 0 March 31st 09 12:50 PM
Pivot Table sort -Excel 2007 Lisa F Excel Discussion (Misc queries) 4 November 6th 08 11:37 PM
Pivot Table Data Column Sort Excel 2007 unclemuffin Excel Discussion (Misc queries) 1 October 31st 08 12:58 PM
Excel 2007 can not filter / sort in sheet with 657,000 rows Charlie Ruddy Excel Discussion (Misc queries) 1 December 30th 07 01:17 AM
is teher any way to copy excel sheet on microsoft word....... naughtyboy Excel Discussion (Misc queries) 1 August 13th 06 10:59 PM


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