#1   Report Post  
Big Tony
 
Posts: n/a
Default Sort Macro

I would like to be able to sort the same column in all worksheets in a
workbook. I found two macros that were similar in this discussion group but
have not been able to make them work. The key column in each worksheet has a
different number of rows but it is always the same column.

Thanks in advance for your assistance.
  #2   Report Post  
 
Posts: n/a
Default

what have you done so far to make them work?
if you pasted them in the vb editor then
toolsmacromacrosselect macrorun should do it.
or alt+F8select macrorun

-----Original Message-----
I would like to be able to sort the same column in all

worksheets in a
workbook. I found two macros that were similar in this

discussion group but
have not been able to make them work. The key column in

each worksheet has a
different number of rows but it is always the same column.

Thanks in advance for your assistance.
.

  #3   Report Post  
Big Tony
 
Posts: n/a
Default

I have this macro:

Sub SortCombo()
' This works on all worksheets
Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
Range("A1").Select
Range("A1:A245").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next ws
Application.ScreenUpdating = True
End Sub

I cannot figure out how to start in specified column (say column 8) where
columns are of different length in each worksheet. I know it has something
to do with the Columns() command maybe coupled with the With command.

" wrote:

what have you done so far to make them work?
if you pasted them in the vb editor then
toolsmacromacrosselect macrorun should do it.
or alt+F8select macrorun

-----Original Message-----
I would like to be able to sort the same column in all

worksheets in a
workbook. I found two macros that were similar in this

discussion group but
have not been able to make them work. The key column in

each worksheet has a
different number of rows but it is always the same column.

Thanks in advance for your assistance.
.


  #4   Report Post  
 
Posts: n/a
Default

hi again
this macro sort column A only
range("A1").select = go to A1
range("A1:A245").sort = sort this range only
it looks like it is sort combo box contents all though i
can imagine a combo box range on every sheet that is that
big. odd.
anyway, column 8 is H so in your macro change the line
Range("A1:A245").Sort Key1:=Range("A2") to
Selection.sort Key1:=Range("H2")
that you make it work
it should sort all sheet in your file by column H.
good luck

-----Original Message-----
I have this macro:

Sub SortCombo()
' This works on all worksheets
Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
Range("A1").Select
Range("A1:A245").Sort Key1:=Range("A2"),

Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next ws
Application.ScreenUpdating = True
End Sub

I cannot figure out how to start in specified column (say

column 8) where
columns are of different length in each worksheet. I

know it has something
to do with the Columns() command maybe coupled with the

With command.

" wrote:

what have you done so far to make them work?
if you pasted them in the vb editor then
toolsmacromacrosselect macrorun should do it.
or alt+F8select macrorun

-----Original Message-----
I would like to be able to sort the same column in all

worksheets in a
workbook. I found two macros that were similar in

this
discussion group but
have not been able to make them work. The key column

in
each worksheet has a
different number of rows but it is always the same

column.

Thanks in advance for your assistance.
.


.

  #5   Report Post  
Big Tony
 
Posts: n/a
Default

I am getting a run-time error '1004'. Application_defined or Object-defined
error. Here is the modified code.
Debugger points to the Selection.SortKey1 statement. I guess I nedd lessons
on understanding what the debugger is trying to tell me.

Sub SortCombo()
' This works on all worksheets
Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
Range("G1").Select
Selection.Sort Key1:=Range("G2"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next ws
Application.ScreenUpdating = True
End Sub

" wrote:

hi again
this macro sort column A only
range("A1").select = go to A1
range("A1:A245").sort = sort this range only
it looks like it is sort combo box contents all though i
can imagine a combo box range on every sheet that is that
big. odd.
anyway, column 8 is H so in your macro change the line
Range("A1:A245").Sort Key1:=Range("A2") to
Selection.sort Key1:=Range("H2")
that you make it work
it should sort all sheet in your file by column H.
good luck

-----Original Message-----
I have this macro:

Sub SortCombo()
' This works on all worksheets
Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
Range("A1").Select
Range("A1:A245").Sort Key1:=Range("A2"),

Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next ws
Application.ScreenUpdating = True
End Sub

I cannot figure out how to start in specified column (say

column 8) where
columns are of different length in each worksheet. I

know it has something
to do with the Columns() command maybe coupled with the

With command.

" wrote:

what have you done so far to make them work?
if you pasted them in the vb editor then
toolsmacromacrosselect macrorun should do it.
or alt+F8select macrorun

-----Original Message-----
I would like to be able to sort the same column in all
worksheets in a
workbook. I found two macros that were similar in

this
discussion group but
have not been able to make them work. The key column

in
each worksheet has a
different number of rows but it is always the same

column.

Thanks in advance for your assistance.
.


.


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
Zip Code Macro Ken Wright Excel Worksheet Functions 0 December 9th 04 07:55 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
Macro Formula revision? Mark Excel Worksheet Functions 1 November 28th 04 01:43 AM
Macro for multiple charts JS Excel Worksheet Functions 1 November 19th 04 03:44 AM
Macro to sort by cell colour CoZ Excel Worksheet Functions 1 November 16th 04 05:52 PM


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