Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ron Ron is offline
external usenet poster
 
Posts: 250
Default Sorting - should have been easy

I have a worksheet open, so it is the active worksheet and did some stuff,
ending with 27 rows (number of rows will vary each day, but should get above
35 to 40), A-E. Need to sort from A5 down. Started at A1. Recording Macro
said:

ActiveCell.Offset(4, 0).Range("A1:E31").Select
ActiveWorkbook.Worksheets("prysm06-17-09").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("prysm06-17-09").Sort.SortFields.Add Key:= _
ActiveCell.Range("A1:A23"), SortOn:=xlSortOnValues,
Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("prysm06-17-09").Sort
.SetRange ActiveCell.Range("A1:E23")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

I want to use this on a different file each day, so name wil be different.
How do I get past ActiveWorkbook.Worksheets("prysm06-17-09"). and just sort
on the sheet that open, with out naming the file each time. My syntax
sucks.... :-)

Thanks,

Ron
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Ron is offline
external usenet poster
 
Posts: 250
Default Sorting - should have been easy

Guess I wasn't patient enough. Changed it to ActiveWorkbook.ActiveSheet.Sort
and it worked.

Thanks anyway.

"Ron" wrote:

I have a worksheet open, so it is the active worksheet and did some stuff,
ending with 27 rows (number of rows will vary each day, but should get above
35 to 40), A-E. Need to sort from A5 down. Started at A1. Recording Macro
said:

ActiveCell.Offset(4, 0).Range("A1:E31").Select
ActiveWorkbook.Worksheets("prysm06-17-09").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("prysm06-17-09").Sort.SortFields.Add Key:= _
ActiveCell.Range("A1:A23"), SortOn:=xlSortOnValues,
Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("prysm06-17-09").Sort
.SetRange ActiveCell.Range("A1:E23")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

I want to use this on a different file each day, so name wil be different.
How do I get past ActiveWorkbook.Worksheets("prysm06-17-09"). and just sort
on the sheet that open, with out naming the file each time. My syntax
sucks.... :-)

Thanks,

Ron

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Sorting - should have been easy

Option Explicit
Sub test()
Dim source As Range
With ActiveSheet
Set source = .Range(.Range("A5"), .Range("E5").End(xlDown))
End With

source.Sort source.Range("A1"), xlAscending


End Sub


"Ron" wrote in message
...
Guess I wasn't patient enough. Changed it to
ActiveWorkbook.ActiveSheet.Sort
and it worked.

Thanks anyway.

"Ron" wrote:

I have a worksheet open, so it is the active worksheet and did some
stuff,
ending with 27 rows (number of rows will vary each day, but should get
above
35 to 40), A-E. Need to sort from A5 down. Started at A1. Recording
Macro
said:

ActiveCell.Offset(4, 0).Range("A1:E31").Select
ActiveWorkbook.Worksheets("prysm06-17-09").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("prysm06-17-09").Sort.SortFields.Add Key:=
_
ActiveCell.Range("A1:A23"), SortOn:=xlSortOnValues,
Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("prysm06-17-09").Sort
.SetRange ActiveCell.Range("A1:E23")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

I want to use this on a different file each day, so name wil be
different.
How do I get past ActiveWorkbook.Worksheets("prysm06-17-09"). and just
sort
on the sheet that open, with out naming the file each time. My syntax
sucks.... :-)

Thanks,

Ron


  #4   Report Post  
Posted to microsoft.public.excel.programming
Ron Ron is offline
external usenet poster
 
Posts: 250
Default Sorting - should have been easy

Thanks, Patrick...the more I do in Excel, the more I know how much I can't
do.....

Ron

"Patrick Molloy" wrote:

Option Explicit
Sub test()
Dim source As Range
With ActiveSheet
Set source = .Range(.Range("A5"), .Range("E5").End(xlDown))
End With

source.Sort source.Range("A1"), xlAscending


End Sub


"Ron" wrote in message
...
Guess I wasn't patient enough. Changed it to
ActiveWorkbook.ActiveSheet.Sort
and it worked.

Thanks anyway.

"Ron" wrote:

I have a worksheet open, so it is the active worksheet and did some
stuff,
ending with 27 rows (number of rows will vary each day, but should get
above
35 to 40), A-E. Need to sort from A5 down. Started at A1. Recording
Macro
said:

ActiveCell.Offset(4, 0).Range("A1:E31").Select
ActiveWorkbook.Worksheets("prysm06-17-09").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("prysm06-17-09").Sort.SortFields.Add Key:=
_
ActiveCell.Range("A1:A23"), SortOn:=xlSortOnValues,
Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("prysm06-17-09").Sort
.SetRange ActiveCell.Range("A1:E23")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

I want to use this on a different file each day, so name wil be
different.
How do I get past ActiveWorkbook.Worksheets("prysm06-17-09"). and just
sort
on the sheet that open, with out naming the file each time. My syntax
sucks.... :-)

Thanks,

Ron


  #5   Report Post  
Posted to microsoft.public.excel.programming
Ron Ron is offline
external usenet poster
 
Posts: 250
Default Sorting - should have been easy


That worked so much better.

Thanks Patrick

Ron

"Patrick Molloy" wrote:

Option Explicit
Sub test()
Dim source As Range
With ActiveSheet
Set source = .Range(.Range("A5"), .Range("E5").End(xlDown))
End With

source.Sort source.Range("A1"), xlAscending


End Sub


"Ron" wrote in message
...
Guess I wasn't patient enough. Changed it to
ActiveWorkbook.ActiveSheet.Sort
and it worked.

Thanks anyway.

"Ron" wrote:

I have a worksheet open, so it is the active worksheet and did some
stuff,
ending with 27 rows (number of rows will vary each day, but should get
above
35 to 40), A-E. Need to sort from A5 down. Started at A1. Recording
Macro
said:

ActiveCell.Offset(4, 0).Range("A1:E31").Select
ActiveWorkbook.Worksheets("prysm06-17-09").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("prysm06-17-09").Sort.SortFields.Add Key:=
_
ActiveCell.Range("A1:A23"), SortOn:=xlSortOnValues,
Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("prysm06-17-09").Sort
.SetRange ActiveCell.Range("A1:E23")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

I want to use this on a different file each day, so name wil be
different.
How do I get past ActiveWorkbook.Worksheets("prysm06-17-09"). and just
sort
on the sheet that open, with out naming the file each time. My syntax
sucks.... :-)

Thanks,

Ron


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
Another sorting question - easy one! Terri[_2_] New Users to Excel 5 March 17th 08 12:29 PM
Easy Sorting for Senior mgt Tsunami3169 Excel Programming 3 January 5th 07 03:52 PM
Pivot table sorting, should be easy I think mcarrington Excel Discussion (Misc queries) 1 June 27th 06 03:14 AM
Easy Sorting Question Yupkwondo Excel Discussion (Misc queries) 4 April 1st 06 01:13 PM
How do I group multiple lines of excel info for easy sorting ericsayang New Users to Excel 2 January 12th 06 08:06 PM


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