Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Code Not Working Properly Anymore

Try something like the following:

Dim StartRow As Long
Dim EndRow As Long
Dim LastRow As Long
Dim L As Long
Dim N As Long
Dim WS As Worksheet

Set WS = Worksheets("List")
StartRow = 1 '<<<<< adjust as necessary
With WS
.Unprotect
For N = 1 To 7 ' cols A - G
LastRow = .Cells(.Rows.Count, N).End(xlUp).Row
If LastRow L Then
L = LastRow
End If
Next N
.Range(.Cells(StartRow, "A"), .Cells(L, "G")).Sort _
key1:=.Cells(StartRow, "F"), order1:=xlAscending
.Protect
End With

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Fri, 14 Aug 2009 08:25:46 -0700 (PDT), zeetoe04
wrote:

I've been using the below code for my spreadsheet to sort this group
of data. It was working fine until today - not sure what even happened
that would change it. What it should be doing is going ot this tab,
unprotecting it, selecting all of the data (Columns A-G always, its
the rows down that fluctuates), sorting it by F3, then reprotecting
the sheet.

Now its only sorting the first four columns (A-D). Any assistance?



Sheets("List").Select
ActiveSheet.Unprotect
Range("A3").Select
Range(ActiveCell.End(xlDown), ActiveCell.End(xlToRight)).Select
Selection.Sort Key1:=Range("F3"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
Range("a1").Select
ActiveSheet.Protect

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
Please help VBA code not working properly send email when due dates Tia[_3_] Excel Worksheet Functions 0 July 21st 09 08:37 AM
format code not working properly DavidH56 Excel Programming 3 March 28th 09 09:31 PM
VBA Excel code not working properly (HELP!) zulfer7 Excel Discussion (Misc queries) 3 April 5th 07 10:49 PM
Code to insert functions not working anymore Mike K Excel Programming 2 June 22nd 06 01:54 PM
code not working properly - VBA beginner (random numbers generation, no repeats) msburza Excel Programming 4 May 11th 06 05:59 PM


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