#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default Is not sorting

I'm new in macro programming and it is not sorting. Can someone help me?

This is the code:

SortData:

'Sort Data worksheet
Dim myrange As Range
Dim LastRow As Variant

Worksheets("Data").Select

'Establish range for sort

'Get the last row of worksheet Data
LastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row

Set myrange = Range("B10:S" & LastRow)

'Sorts ascending by Section ID ("H10")

With myrange
.Sort Key1:=Range("H10"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Is not sorting

Hmm, your macro is sorting for me. You might try changing the part with:

Header:=xlGuess
to
Header:=xlNo 'or xlYes, depending on if row 10 is headers or not
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Gisela" wrote:

I'm new in macro programming and it is not sorting. Can someone help me?

This is the code:

SortData:

'Sort Data worksheet
Dim myrange As Range
Dim LastRow As Variant

Worksheets("Data").Select

'Establish range for sort

'Get the last row of worksheet Data
LastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row

Set myrange = Range("B10:S" & LastRow)

'Sorts ascending by Section ID ("H10")

With myrange
.Sort Key1:=Range("H10"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default Is not sorting

I made the changes and still not working. By the way, H10 ist not header.
Help!!

"Luke M" wrote:

Hmm, your macro is sorting for me. You might try changing the part with:

Header:=xlGuess
to
Header:=xlNo 'or xlYes, depending on if row 10 is headers or not
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Gisela" wrote:

I'm new in macro programming and it is not sorting. Can someone help me?

This is the code:

SortData:

'Sort Data worksheet
Dim myrange As Range
Dim LastRow As Variant

Worksheets("Data").Select

'Establish range for sort

'Get the last row of worksheet Data
LastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row

Set myrange = Range("B10:S" & LastRow)

'Sorts ascending by Section ID ("H10")

With myrange
.Sort Key1:=Range("H10"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Is not sorting

'Sort Data worksheet
Dim myrange As Range
Dim LastRow As Variant

with Worksheets("Data")
'Establish range for sort
'Get the last row of worksheet Data
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
Set myrange = .Range("B10:S" & LastRow)

'Sorts ascending by Section ID ("H10")

With myrange
.Sort Key1:=.columns(7), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End With

I would never let excel guess if my data had headers--if it's my data, I should
know and specify it.

If this doesn't help, you should explain how the sort fails. If you have simple
formulas like:

='Othersheet'!a99
in column H of the Data worksheet, then excel won't sort your data the way you
want.



Gisela wrote:

I'm new in macro programming and it is not sorting. Can someone help me?

This is the code:

SortData:

'Sort Data worksheet
Dim myrange As Range
Dim LastRow As Variant

Worksheets("Data").Select

'Establish range for sort

'Get the last row of worksheet Data
LastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row

Set myrange = Range("B10:S" & LastRow)

'Sorts ascending by Section ID ("H10")

With myrange
.Sort Key1:=Range("H10"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default Is not sorting

Thanks! It worked.

"Dave Peterson" wrote:

'Sort Data worksheet
Dim myrange As Range
Dim LastRow As Variant

with Worksheets("Data")
'Establish range for sort
'Get the last row of worksheet Data
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
Set myrange = .Range("B10:S" & LastRow)

'Sorts ascending by Section ID ("H10")

With myrange
.Sort Key1:=.columns(7), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End With

I would never let excel guess if my data had headers--if it's my data, I should
know and specify it.

If this doesn't help, you should explain how the sort fails. If you have simple
formulas like:

='Othersheet'!a99
in column H of the Data worksheet, then excel won't sort your data the way you
want.



Gisela wrote:

I'm new in macro programming and it is not sorting. Can someone help me?

This is the code:

SortData:

'Sort Data worksheet
Dim myrange As Range
Dim LastRow As Variant

Worksheets("Data").Select

'Establish range for sort

'Get the last row of worksheet Data
LastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row

Set myrange = Range("B10:S" & LastRow)

'Sorts ascending by Section ID ("H10")

With myrange
.Sort Key1:=Range("H10"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With


--

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
Sorting Values Without Sorting Formulas SBX Excel Discussion (Misc queries) 2 April 12th 09 11:17 PM
Automatic sorting (giving max and min) based on custom sorting lis Joe Lewis[_2_] Excel Worksheet Functions 4 November 23rd 08 05:12 AM
Sorting VLookup vs Sorting SumProduct Lauren Excel Discussion (Misc queries) 1 August 21st 07 12:19 AM
Sorting: Sorting by the First Character dzuy Excel Discussion (Misc queries) 2 June 22nd 06 08:27 PM
Sorting harvindersingh1 Excel Discussion (Misc queries) 3 April 18th 06 07:06 AM


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