+ Reply to Thread
Results 1 to 5 of 5

block relative addressing..

Hybrid View

  1. #1
    Registered User
    Join Date
    10-16-2008
    Location
    iowa
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    63

    block relative addressing..

    I have a named block, used to sort a list of data. But I names the block one row higher to include the headers, so that inserts at the top row of the data would not fall out of the named range.

    Then I want to sort the data, but not include the header row.

    How?

    What I want to say in the sort macro is something like:
    cell_range( top_row(Data)-1, Bottom_Row(Data) )

    Or, to have two names, with one defined in terms of the other:
    Data_sort = Data_big - Toprow(Data_big)
    Last edited by guthrie; 10-23-2008 at 08:30 AM. Reason: solved

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello guthrie,

    Welcome to the Forum!

    Here is a code example in VBA of resizing a range to remove the header row - row 1.
    Sub RemoveHeaderRow()
    
      Dim Rng As Range
      
       'Set Rng equal to the block range A1:I10
        Set Rng = Range("A1:I10")
        
       'Reset Rng equal to the block range minus row A1:I1
        Set Rng = Rng.Offset(1, 0).Resize(Rng.Rows.Count - 1)
    
       'Sort the Range
        Rng.Sort
       
    End Sub
    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    06-14-2008
    Posts
    153
    Hi,
    aa
    In the sort dialog box you have an option to specify whether your data has a header row or not. If you specify a header row then the first row will be excluded from the sort.

    If you are using a macro then you have to include that option as one of the sort parameters. Your VBA code will be something like this:

    Range("A10:B14").Select
    Selection.Sort Key1:=Range("A11"), Order1:=xlAscending, Header:=xlYes, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
    Regards.
    Welcome to: http://www.exceldigest.com/myblog/
    "Excel help for the rest of us"

  4. #4
    Registered User
    Join Date
    10-16-2008
    Location
    iowa
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    63

    Block reative addressing - solutions

    Many thanks to you both - good solutions!

    Greg

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Problem solved ? Please change the prefix of your original post accordingly

+ 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. Determining relative file path macro
    By ctmurray in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-18-2007, 12:25 AM
  2. Prevent Yellow color from printing. Make visible gridlines in a shaded block
    By johnnywinter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-20-2007, 08:22 PM
  3. Gantt chart using relative dates?
    By Poops in forum Excel General
    Replies: 1
    Last Post: 06-09-2007, 02:29 PM
  4. Using Relative & Abolute addressing
    By dar byrne in forum Excel General
    Replies: 4
    Last Post: 11-09-2006, 07:51 AM

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