#1   Report Post  
Posted to microsoft.public.excel.misc
Chey
 
Posts: n/a
Default macro

I have a protect excel spreadsheet that has 12 tabs that people enter in
there children's attendance with o and / they also type in the childrens
names. Is there a way to do a macro, or something that will allow to sort
all the names on all 12 tabs so the children can be in alphabetical order? I
also have formulas written so it calculates o as 1 and / as .5. I hope that
sorting does not interfier with that.
Thanks
Chey
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default macro


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

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

Chey wrote:

I have a protect excel spreadsheet that has 12 tabs that people enter in
there children's attendance with o and / they also type in the childrens
names. Is there a way to do a macro, or something that will allow to sort
all the names on all 12 tabs so the children can be in alphabetical order? I
also have formulas written so it calculates o as 1 and / as .5. I hope that
sorting does not interfier with that.
Thanks
Chey


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
Chey
 
Posts: n/a
Default macro

I already have that one down. But what the problem peopel were running into
is wanting to sort between worksheets. Is there a way for that?

"Dave Peterson" wrote:


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

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

Chey wrote:

I have a protect excel spreadsheet that has 12 tabs that people enter in
there children's attendance with o and / they also type in the childrens
names. Is there a way to do a macro, or something that will allow to sort
all the names on all 12 tabs so the children can be in alphabetical order? I
also have formulas written so it calculates o as 1 and / as .5. I hope that
sorting does not interfier with that.
Thanks
Chey


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default macro

You mean that you have data that should switch sheets when you sort all the
data?

If yes, then there's nothing built into excel that'll do that.

In fact, maybe excel isn't the correct tool for the job. If you have lots of
records, maybe using a real database program would be a better solution.

Chey wrote:

I already have that one down. But what the problem peopel were running into
is wanting to sort between worksheets. Is there a way for that?

"Dave Peterson" wrote:


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

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

Chey wrote:

I have a protect excel spreadsheet that has 12 tabs that people enter in
there children's attendance with o and / they also type in the childrens
names. Is there a way to do a macro, or something that will allow to sort
all the names on all 12 tabs so the children can be in alphabetical order? I
also have formulas written so it calculates o as 1 and / as .5. I hope that
sorting does not interfier with that.
Thanks
Chey


--

Dave Peterson


--

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
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
macro with F9 Kenny Excel Discussion (Misc queries) 1 August 3rd 05 02:41 PM
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM


All times are GMT +1. The time now is 03:42 PM.

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"