ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   sorting (https://www.excelbanter.com/excel-discussion-misc-queries/164652-sorting.html)

peyman

sorting
 
hi,
I've a macro for sorting a selected range in a worksheet.the workbook is
SHARED.the problem is when I sort it in my file, the macro works well but for
the other users nothing happens and the range is not sorted?!

Sub Rectangle1954_Click()
Dim myRng As Range
Set myRng = Selection.Areas(1)
With myRng

.Sort_
key1:=Columns("C"), order1:=xlAscending, DataOption1:=xlSortNormal,_
key2:=Columns("B"), order2:=xlAscending, DataOption2:=xlSortTextAsNumbers,_
Key3:=Columns("F"), order3:=xlAscending, DataOption3:=xlSortNormal

End With
End Sub
any help?


Dave Peterson

sorting
 
I'm gonna make the same guess that I did to your previous post:

Maybe...

With myRng
.Sort key1:=.Columns(3), order1:=xlAscending, _
key2:=.Columns(2), order2:=xlAscending, _
key3:=.Columns(6), order3:=xlAscending, _
header:=xlNo, MatchCase:=False, Orientation:=xlTopToBottom
End With

You may want to check to see if that Area has at least 6 columns, too:

if myrng.columns.count < 6 then
'error message or resize or ????

peyman wrote:

hi,
I've a macro for sorting a selected range in a worksheet.the workbook is
SHARED.the problem is when I sort it in my file, the macro works well but for
the other users nothing happens and the range is not sorted?!

Sub Rectangle1954_Click()
Dim myRng As Range
Set myRng = Selection.Areas(1)
With myRng

.Sort_
key1:=Columns("C"), order1:=xlAscending, DataOption1:=xlSortNormal,_
key2:=Columns("B"), order2:=xlAscending, DataOption2:=xlSortTextAsNumbers,_
Key3:=Columns("F"), order3:=xlAscending, DataOption3:=xlSortNormal

End With
End Sub
any help?


--

Dave Peterson

peyman

sorting
 
hi Dave.There is not any problem in selecting the range.because the number of
columns in each selection is the same(B to J)but the number of rows may
varies.the only concern is I don't know how the sorted range for one user can
not be visible to others.when the other users save to see the user's changes,
no thing happens and the range is still unsorted.!!!

"Dave Peterson" wrote:

I'm gonna make the same guess that I did to your previous post:

Maybe...

With myRng
.Sort key1:=.Columns(3), order1:=xlAscending, _
key2:=.Columns(2), order2:=xlAscending, _
key3:=.Columns(6), order3:=xlAscending, _
header:=xlNo, MatchCase:=False, Orientation:=xlTopToBottom
End With

You may want to check to see if that Area has at least 6 columns, too:

if myrng.columns.count < 6 then
'error message or resize or ????

peyman wrote:

hi,
I've a macro for sorting a selected range in a worksheet.the workbook is
SHARED.the problem is when I sort it in my file, the macro works well but for
the other users nothing happens and the range is not sorted?!

Sub Rectangle1954_Click()
Dim myRng As Range
Set myRng = Selection.Areas(1)
With myRng

.Sort_
key1:=Columns("C"), order1:=xlAscending, DataOption1:=xlSortNormal,_
key2:=Columns("B"), order2:=xlAscending, DataOption2:=xlSortTextAsNumbers,_
Key3:=Columns("F"), order3:=xlAscending, DataOption3:=xlSortNormal

End With
End Sub
any help?


--

Dave Peterson


Dave Peterson

sorting
 
I don't use shared workbooks.

Sorry.

peyman wrote:

hi Dave.There is not any problem in selecting the range.because the number of
columns in each selection is the same(B to J)but the number of rows may
varies.the only concern is I don't know how the sorted range for one user can
not be visible to others.when the other users save to see the user's changes,
no thing happens and the range is still unsorted.!!!

"Dave Peterson" wrote:

I'm gonna make the same guess that I did to your previous post:

Maybe...

With myRng
.Sort key1:=.Columns(3), order1:=xlAscending, _
key2:=.Columns(2), order2:=xlAscending, _
key3:=.Columns(6), order3:=xlAscending, _
header:=xlNo, MatchCase:=False, Orientation:=xlTopToBottom
End With

You may want to check to see if that Area has at least 6 columns, too:

if myrng.columns.count < 6 then
'error message or resize or ????

peyman wrote:

hi,
I've a macro for sorting a selected range in a worksheet.the workbook is
SHARED.the problem is when I sort it in my file, the macro works well but for
the other users nothing happens and the range is not sorted?!

Sub Rectangle1954_Click()
Dim myRng As Range
Set myRng = Selection.Areas(1)
With myRng

.Sort_
key1:=Columns("C"), order1:=xlAscending, DataOption1:=xlSortNormal,_
key2:=Columns("B"), order2:=xlAscending, DataOption2:=xlSortTextAsNumbers,_
Key3:=Columns("F"), order3:=xlAscending, DataOption3:=xlSortNormal

End With
End Sub
any help?


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 08:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com