Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.excel.programming > #109589

Re: Multiple Sort Ranges via VBA Q

From Claus Busch <claus_busch@t-online.de>
Newsgroups microsoft.public.excel.programming
Subject Re: Multiple Sort Ranges via VBA Q
Date 2016-11-16 15:18 +0100
Organization A noiseless patient Spider
Message-ID <o0hppp$o7j$1@dont-email.me> (permalink)
References <89df722d-db65-497e-939a-818b9ca108df@googlegroups.com>

Show all headers | View raw


Hi Sean,

Am Wed, 16 Nov 2016 06:05:01 -0800 (PST) schrieb seanryanie@yahoo.co.uk:

> Code below sorts 2 Range Names called "Sort1" & "Sort2". It uses Column I as the Sort field from Largest down
> 
> I have over 50 of these Ranges, is there anyway to short circuit the code below to include all 50 of these Sort Ranges?

if the ranges have always 7 rows you could do it with a loop:

Sub SpecialSort()
Dim i As Long, LRow As Long

With Sheets("Input")
    LRow = .Cells(.Rows.Count, "I").End(xlUp).Row
    For i = 15 To LRow Step 8
        .Range("F" & i & ":I" & i + 7).Sort Key1:=Range("I" & i), _
            order1:=xlDescending, Header:=xlNo
    Next
End With
End Sub

Else you could write all ranges in an array and then step through this
array.


Regards
Claus B.
-- 
Windows10
Office 2016

Back to microsoft.public.excel.programming | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Multiple Sort Ranges via VBA Q seanryanie@yahoo.co.uk - 2016-11-16 06:05 -0800
  Re: Multiple Sort Ranges via VBA Q Claus Busch <claus_busch@t-online.de> - 2016-11-16 15:18 +0100
    Re: Multiple Sort Ranges via VBA Q seanryanie@yahoo.co.uk - 2016-11-16 06:33 -0800
    Re: Multiple Sort Ranges via VBA Q seanryanie@yahoo.co.uk - 2016-11-16 10:56 -0800
      Re: Multiple Sort Ranges via VBA Q Claus Busch <claus_busch@t-online.de> - 2016-11-16 20:03 +0100
        Re: Multiple Sort Ranges via VBA Q seanryanie@yahoo.co.uk - 2016-11-16 12:02 -0800

csiph-web