+ Reply to Thread
Results 1 to 2 of 2

VBA code to sort data either within one large worksheet or across several worksheets

  1. #1
    Registered User
    Join Date
    05-24-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    16

    VBA code to sort data either within one large worksheet or across several worksheets

    Good evening,

    I hope someone can help me with this as it's got be stumped.

    I have one large spreadsheet, which several rows of data for each well, and there are 350 wells (so thousands of rows). Column A contains the well names, Column D contains codes which I will be using in another piece of software. And Columns B and C are From and To, respectively, which increase in depth. An example is below:

    BHID FROM TO NLITH-New
    BH-1 4 18.55 4
    BH-1 18.55 116.09 9
    BH-1 117.2 117.84 6
    BH-1 116.09 117.2 10
    BH-1 125.27 126.04 5
    BH-1 117.84 125.27 11
    BH-1 126.04 129.68 21
    BH-1 129.68 133.72 19
    BH-1 133.72 138.15 12
    BH-1 138.15 145.55 20
    BH-1 145.55 153.77 13
    BH-1 153.77 160.53 6
    BH-1 160.53 161.18 14
    BH-1 161.18 162 22

    Using VBA, I've both seperated out the worksheet into seperated worksheets, by well name, and then saved these worksheets as seperate text files (tab delimited). So I have a master worksheet and then individual ones for each well.

    In order for me to load these files into my software, the data in both Columns B and C needs to be ascending. However, I've just noticed that, as highlighted in red for well BH-1 shown above, there are some rows mixed around for each well. This is very annoying and is the case for all the wells!

    I would like to know if I can, using a VBA, sort the data in columns B and C into ascending order? I'm not sure if I can do this in the very large spreadsheet, as it would need to apply to each column but for each well at a time rather than the whole column at once. Maybe this will be easier across the individual spreadsheets?

    I apologise if this sounds a bit complicated. Happy to provide some clarity!

    Many thanks in advance.

    Georgina

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA code to sort data either within one large worksheet or across several worksheets

    Not sure I understand, but does this help? Test on a copy first to see if it is what you want.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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