Results 1 to 10 of 19

Thread: Sort Range Using VBA And Ignoring Or Discarding Blank Rows

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    try this one and let me know if you get any message box pop ups ?

    Code:
    Option Explicit
    
    Sub OSumRank()
    
        Sheets("OSum").Select
        Application.ScreenUpdating = False
        Columns("R:AC").EntireColumn.AutoFit
        
        Dim r       As Range
        Dim bCells  As Range
        
        Range("R3:AC17").Copy
        Range("AE3").Select
        Selection.PasteSpecial Paste:=xlPasteValues
                
        Set r = Range("ae3:ap17")
        
        Const fNum = -9999999.99
        
        With r
            On Error Resume Next
            Set bCells = .SpecialCells(4)
            If Not bCells Is Nothing Then
                MsgBox dcell.Address
            Else
                .Sort Key1:=Range("AE3"), Order1:=xlAscending, Key2:=Range( _
                "AL3"), Order2:=xlDescending, Key3:=Range("AM3"), Order3:=xlAscending, _
                Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
                xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
                DataOption3:=xlSortNormal
            End If
            .Replace fNum, vbNullString, 1
        End With
    
    End Sub
    Last edited by Admin; 02-05-2014 at 03:43 PM.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

Similar Threads

  1. Delete blank rows
    By dhivya.enjoy in forum Excel Help
    Replies: 5
    Last Post: 10-23-2013, 10:04 PM
  2. Insert blank rows based on cell value
    By muhammad susanto in forum Excel Help
    Replies: 13
    Last Post: 09-11-2013, 06:18 AM
  3. Replies: 6
    Last Post: 08-14-2013, 04:25 PM
  4. Replies: 2
    Last Post: 05-06-2011, 02:59 AM
  5. Deleting blank rows
    By Rasm in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 04-14-2011, 03:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •