Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Newbie : Help with sort via Excel code

I keep getting this error message with my spreadsheet and I do not
know what it means. Can anyone help.

Error Message :
The sort reference is not valid. Make sure that it's within the data
you want to sort, and the first SORT BY box isn't the same or blank


Below is my source code:
For Each w In Worksheets
w.Activate
ActiveCell.SpecialCells(xlLastCell).Select
lnRange = CInt(Mid(ActiveCell.Address(RowAbsolute:=False), 3, 5))
lcCellRange = "A3:G" & Trim(Str(lnRange - 1))
w.Range(lcCellRange).Select
Selection.Sort Key1:=Range("C3"), Order1:=xlAscending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

w.Range("A1").Select
Next w
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Newbie : Help with sort via Excel code

Try this whe
n = First Row to be sorted
a = Last Row to be sorted
c = the number of the column to sort by (ie. Column "C" = 3, Column "E"
= 5 etc.)

For x = n To a
aNam = bp.Cells(x, 3).Value
z = x
For y = x + 1 To a
If bp.Cells(y, 3).Value < aNam Then
aNam = bp.Cells(y, 3).Value
z = y
End If
Next y

If z < x Then
bp.Rows(z).Cut
bp.Rows(x).Insert
End If
Next x


---
Message posted from http://www.ExcelForum.com/

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 sort is an Excel problem even when using the special cat. camead Excel Discussion (Misc queries) 2 March 31st 05 01:15 AM
Newbie Question: Data/Sort [email protected] New Users to Excel 1 February 21st 05 11:37 PM
VBA Newbie: Help with Do Loop code Carl Excel Discussion (Misc queries) 3 December 2nd 04 07:04 PM
Sort (in Excel) from code in MSProject Peter Darmody Excel Programming 2 October 16th 03 04:36 AM
Newbie : Autofilter thru code ? Rich[_16_] Excel Programming 2 October 5th 03 07:27 PM


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