Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Dale60
 
Posts: n/a
Default Sorting Excel columns in several worksheets at once.

I have information in several excel worksheets. All worksheets are formated
the same within the file. How do I sort all the worksheets at once by one of
the columns, for instance sort all worksheets by column A.
  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Sorting Excel columns in several worksheets at once.

You could record a macro that sorts the data the way you want. Then run that
same code for each worksheet that you need sorted.

For example, this expects headers in row 1 of each worksheet. It sorts columns
A:G and determines the last row by the last row used in column A.

And it it uses column 1 (A), column 3 (C), and column 5 (E) as the key columns.

Option Explicit
Sub testme01()

Dim myRng As Range
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
With wks
Set myRng = .Range("a1:G" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

With myRng
.Cells.Sort key1:=.Columns(1), order1:=xlAscending, _
key2:=.Columns(3), order2:=xlAscending, _
key3:=.Columns(5), order3:=xlAscending, _
header:=xlYes
End With
Next wks
End Sub


Dale60 wrote:

I have information in several excel worksheets. All worksheets are formated
the same within the file. How do I sort all the worksheets at once by one of
the columns, for instance sort all worksheets by column A.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Sorting Excel columns in several worksheets at once.

ps.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Dale60 wrote:

I have information in several excel worksheets. All worksheets are formated
the same within the file. How do I sort all the worksheets at once by one of
the columns, for instance sort all worksheets by column A.


--

Dave Peterson
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
Can I add more columns in Excel past column IV Jamie Excel Discussion (Misc queries) 0 December 22nd 05 06:49 PM
loosing columns in excel 2000 Arnold Excel Discussion (Misc queries) 5 December 21st 05 05:52 PM
In Excel, sorting columns automatically by clicking column title Destiny Excel Discussion (Misc queries) 1 June 23rd 05 06:39 PM
Excel Range Value issue (Excel 97 Vs Excel 2003) Keeno Excel Discussion (Misc queries) 2 June 13th 05 02:01 PM
how to increase maximum number of columns in excel 2003 [email protected] Excel Discussion (Misc queries) 1 January 16th 05 08:13 PM


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