Results 1 to 3 of 3

Key1: Range Problem in Data Sort

Threaded View

Ron Greer Key1: Range Problem in Data... 07-24-2012, 10:31 AM
JosephP Re: Key1: Range Problem in... 07-24-2012, 11:53 AM
Ron Greer Re: Key1: Range Problem in... 07-24-2012, 12:18 PM
  1. #1
    Registered User
    Join Date
    07-24-2012
    Location
    Claremore, Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    2

    Key1: Range Problem in Data Sort

    First time Forum user. The Macro below works but I need for the Key1 Range to be the active cell at column "CD" instead of "CD57". In other words, I am doing all of the sorting on a single row but the row number will vary depending on the row number of the active cell.

    Thanks for your help.

    Ron



    Sub Macro2()
    '
    ' Macro1 Macro
    ' Update and Calculate
    '
    ' Keyboard Shortcut: Ctrl+x
    '
        With ActiveCell
            Range(Cells(.Row, "BI"), Cells(.Row, "CB")).Select
        End With
     
        Selection.Copy
        
        With ActiveCell
            Range(Cells(.Row, "CD"), Cells(.Row, "CW")).Select
        End With
        
        
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
        
        With ActiveCell
            Range(Cells(.Row, "CD"), Cells(.Row, "CW")).Select
        End With
    
        
        Selection.Sort _
        Key1:=Range("CD57"), _
        Order1:=xlAscending, Header:=xlGuess _
            , OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _
            DataOption1:=xlSortNormal
        
        
    End Sub
    Last edited by Cutter; 07-24-2012 at 01:04 PM. Reason: Added code tags

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