Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8465547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:04:54+00:00 2026-06-10T15:04:54+00:00

I have a script: Sub wsPOT() Dim wsPOT As Worksheet Dim cel As Range

  • 0

I have a script:

Sub wsPOT()
    Dim wsPOT As Worksheet
    Dim cel As Range
    Dim lastrow As Long, lastrow2 As Long, fstcell As Long, i As Long, Er As Long, lstCol As Long, lstRow As Long

    Set wsPOT = Sheets("PO Tracking")

    With wsPOT
        wsPOT.Range("Q1:U1").Copy
        lastrow = wsPOT.Cells(Rows.Count, "B").End(xlUp).Row
            wsPOT.Range("V1:X1").Copy wsPOT.Range("H3:J" & lastrow)
            wsPOT.Range("N2:O2").Copy wsPOT.Range("N3:O" & lastrow)
            wsPOT.Range("P1:V1").Copy
            wsPOT.Range("B3:H" & lastrow).PasteSpecial xlPasteFormats
            wsPOT.Range("K3:K" & lastrow).Borders.Weight = xlThin


        lastrow = wsPOT.Cells(Rows.Count, "B").End(xlUp).Row
            wsPOT.Range("H:J").Calculate
            wsPOT.Range("B3:K" & lastrow).Sort key1:=Range("H3:H" & lastrow), order1:=xlAscending
        lastrow2 = wsPOT.Cells(Rows.Count, "H").End(xlUp).Row
            wsPOT.Range("B3:K" & lastrow2).Sort key1:=Range("H3:H" & lastrow2), order1:=xlDescending
    End With

End Sub

This is meant to ultimately organize the sheet so that the the late jobs are on top, and then those are organized by oldest to youngest.

It seems not to work. What seems to happen is that the first orginization works fine, but then it seems to ignore the second criteria.

Attached is the sheet, with script.

https://dl.dropbox.com/u/3327208/Excel/Orga.xlsm

If someone can help look at this it be apprecaited.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:04:56+00:00Added an answer on June 10, 2026 at 3:04 pm

    Is this what you are trying?

    Option Explicit
    
    Sub wsPOT()
        Dim wsPOT As Worksheet
        Dim cel As Range
        Dim lastrow As Long, lastrow2 As Long, fstcell As Long
        Dim i As Long, Er As Long, lstCol As Long, lstRow As Long
    
        Set wsPOT = Sheets("PO Tracking")
    
        With wsPOT
            .Range("Q1:U1").Copy
            lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row
            .Range("V1:X1").Copy .Range("H3:J" & lastrow)
            .Range("N2:O2").Copy .Range("N3:O" & lastrow)
            .Range("P1:V1").Copy
            .Range("B3:H" & lastrow).PasteSpecial xlPasteFormats
            .Range("K3:K" & lastrow).Borders.Weight = xlThin
            lastrow = .Cells(.Rows.Count, "H").End(xlUp).Row
            .Range("H:J").Calculate
    
            .Sort.SortFields.Clear
    
            '~~> Sort on Red Icon First, putting it on top
            .Sort.SortFields.Add(.Range("J3:J" & lastrow), _
            xlSortOnIcon, xlAscending, , xlSortNormal).SetIcon Icon:=ActiveWorkbook. _
            IconSets(4).Item(1)
    
            '~~> Sort on Values of Red icon in descending order
            .Sort.SortFields.Add Key:=Range( _
            "J3:J" & lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
            xlSortNormal
    
            '~~> Sort on Green Icon Next, putting it on top after Red
            .Sort.SortFields.Add(.Range("I3:I" & lastrow), _
            xlSortOnIcon, xlAscending, , xlSortNormal).SetIcon Icon:=ActiveWorkbook. _
            IconSets(4).Item(3)
    
            '~~> Sort on Values of Green icon next in descending order
            .Sort.SortFields.Add Key:=Range( _
            "I3:I" & lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
            xlSortNormal
    
            With .Sort
                .SetRange wsPOT.Range("B2:K" & lastrow)
                .Header = xlYes
                .MatchCase = False
                .Orientation = xlTopToBottom
                .SortMethod = xlPinYin
                .Apply
            End With
        End With
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that recursively loops through all the sub directories and compresses
I have A Script that has a Select statement to go to multiple sub
I have a PHP script (index.php) that includes an index.html file in a sub-directory
I have just found a script we are using which has a sub that
I have a script that is copying a folder that contains a couple sub
I have a Perl script which forks a number of sub-processes. I'd like to
Given that we have a script Option Explicit Class CClass Private m_date Private Sub
I have this script, I keep getting an error: Run-time error '1004': Method 'Range'
I have a script that shows some files from a folder. code behind Sub
I have already enabled scripts from Tools->Security->Custom... ...Please help migrate to proper forum/sub-site if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.