PC Review


Reply
Thread Tools Rate Thread

Code Not Working Properly Anymore

 
 
zeetoe04
Guest
Posts: n/a
 
      14th Aug 2009
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 With Quote
 
 
 
 
Susan
Guest
Posts: n/a
 
      14th Aug 2009
possible: cells E, F, & G are now empty, so your range is only being
set through column D?

susan


On Aug 14, 11:25*am, zeetoe04 <kmz...@gmail.com> 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 With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      16th Aug 2009
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 <(E-Mail Removed)>
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to insert functions not working anymore =?Utf-8?B?TWlrZSBL?= Microsoft Excel Programming 2 22nd Jun 2006 01:54 PM
CD-RW not working properly anymore =?Utf-8?B?c2ltb25iNw==?= Windows XP General 4 19th May 2005 03:35 PM
HTTPS - Window. code not working anymore Tersia Ehlert Microsoft ASP .NET 1 10th Jan 2005 02:15 PM
HTTPS - Window. code not working anymore Tersia Ehlert Microsoft Dot NET 1 10th Jan 2005 02:15 PM
HTTPS - Window. code not working anymore Tersia Ehlert Microsoft VB .NET 1 10th Jan 2005 02:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:16 AM.