+ Reply to Thread
Results 1 to 3 of 3

Create a Macro to perform a custom sort on varying number of rows

Hybrid View

Shirley Munro Create a Macro to perform a... 07-29-2013, 02:41 AM
ragulduy Re: Create a Macro to perform... 07-29-2013, 04:46 AM
Shirley Munro Re: Create a Macro to perform... 07-29-2013, 07:09 PM
  1. #1
    Registered User
    Join Date
    09-17-2003
    Location
    Scotland
    Posts
    59

    Create a Macro to perform a custom sort on varying number of rows

    Hi

    I have a macro that I want to use to perform a custom sort on 4 columns. The number of rows varies each time the sort is performed. How can I amend the recorded code so that it will work regardless of the number of rows in the worksheet. Attached is a screenshot of my macro code.
    Attached Images Attached Images

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Create a Macro to perform a custom sort on varying number of rows

    Please post the actual code rather than a screenshot, you won't get as much help if people need to type out your code from a picture! Use code tags (The hash button on the reply toolbar) too.

    Anyway, I'd sggest adding to the top of your code:
    dim last_row
    last_row = Sheets("Breaches").Range("A" & rows.count).end(xlup).row
    and then changing anything that looks like:
    Key:=Range("C2:C204")
    to
    Range("C2:C" & last_row)

  3. #3
    Registered User
    Join Date
    09-17-2003
    Location
    Scotland
    Posts
    59

    Re: Create a Macro to perform a custom sort on varying number of rows

    Thanks for that and also for the advice on sending code itself rather than a screenshot. Worked perfectly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. macro to sort varying number of rows
    By kmfocht in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-26-2009, 05:34 PM
  2. How do I create a Macro to sort data and insert blank rows & subto
    By karinmpfa in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-25-2006, 05:10 PM
  3. Sum varying number of rows
    By LSkarbek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2006, 11:10 AM
  4. Varying Data Sort Macro.
    By MyKool in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2005, 12:20 PM
  5. Using a Macro to perform a VLookup on varying number of rows
    By Shirley Munro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-05-2005, 09:28 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1