Sorting not working
Sorting not working
Sorting not working
Sorting not working
Sorting not working
Sorting not working Sorting not working Sorting not working Sorting not working Sorting not working Sorting not working Sorting not working Sorting not working
Sorting not working Sorting not working
Sorting not working
Go Back  Xtreme Visual Basic Talk > > > > Sorting not working


Reply
 
Thread Tools Display Modes
  #1  
Old 11-29-2017, 08:39 PM
issBloke issBloke is offline
Freshman
 
Join Date: Jul 2006
Location: Australia
Posts: 42
Default Sorting not working


I copied this sort code from another workbook where it is working.
I'm using Excel 2013
Run-time error '1004':
Sort method of Range class failed
The error occurs at line
.Range("A1" & lLastRow).Sort _
Code:
Sub Sort()
Dim wSheet As Worksheet
Dim lLastRow As Long
    Set wSheet = Worksheets("Watch")
        With wSheet
            lLastRow = Cells(Rows.Count, "B").End(xlUp).Row
        .Range("A1" & lLastRow).Sort _
        Key1:=.Range("A1"), _
        Order1:=xlAscending, _
        Header:=xlGuess, OrderCustom:=1, _
        MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
    End With
    Cells(Rows.Count, 1).End(xlUp)(2).Select
    Set wSheet = Nothing
 End Sub
Any help please.
Reply With Quote
  #2  
Old 11-30-2017, 05:11 PM
Cerian Knight's Avatar
Cerian KnightSorting not working Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

Did you mean to do something like:
.Range("A1:A" & cStr(lLastRow)).Sort _
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #3  
Old 11-30-2017, 06:37 PM
issBloke issBloke is offline
Freshman
 
Join Date: Jul 2006
Location: Australia
Posts: 42
Default

Thank you Cerian Knight. I had spent a lot of time on this with no luck, still learning.
Reply With Quote
Reply

Tags
wsheet, sort, set, llastrow.sort, cellsrows.count, error, llastrow, .rangea1, dim, worksheetswatch, worksheet, key1=.rangea1, 1.endxlup2.select, dataoption1=xlsortnormal, orientation=xltoptobottom, order1=xlascending, header=xlguess, ordercustom=1, matchcase=false, b.endxlup.row, workbook, copied, code, excel, failed


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Sorting not working
Sorting not working
Sorting not working Sorting not working
Sorting not working
Sorting not working
Sorting not working Sorting not working Sorting not working Sorting not working Sorting not working Sorting not working Sorting not working
Sorting not working
Sorting not working
 
Sorting not working
Sorting not working
 
-->