+ Reply to Thread
Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    08-31-2009
    Location
    boarders' paradise
    MS-Off Ver
    Excel 2002
    Posts
    92

    Question Hotkey to mark all cells from current to last/first of column ?

    Hi folks.

    Do you know a hotkey which lets me mark all cells from the current one to the last/first of column ?
    In the helpfile there are all sorts of hotkeys for almost any scenario, but it seems to me as if this specific action lacks a hotkey

    Thanks a lot!

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    MS Office Excel 2007
    Posts
    698

    Re: Hotkey to mark all cells from current to last/first of column ?

    Down arrow while holding Ctrl-Shift?
    Regards
    Special-K

    I rarely return to a problem once I've answered it so make sure you clearly define what the trouble is.

  3. #3
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,441

    Re: Hotkey to mark all cells from current to last/first of column ?

    Do you know a hotkey which lets me mark all cells from the current one to the last/first of column ?
    If by "mark" you mean highlight as in selecting cells, then . . .

    Well, Let's say you are in cell A1 and your data extend down to cell A1000

    Make A1 the activecell, the press Ctrl + Shift + down arrow to select the entire range of rows in column-A. (Will have press more than once if there are blank rows in between.)

    If you want to move across the columns, then
    Ctrl + Shift + right arrow

    To select the entire current region
    Ctrl + A

    So if data are in A1:Z1000, Ctrl + A will select that range.

    If this is not what you are after, then explain what you mean by "mark all cells"
    Last edited by Palmetto; 08-31-2009 at 04:49 PM.

  4. #4
    Registered User
    Join Date
    08-31-2009
    Location
    boarders' paradise
    MS-Off Ver
    Excel 2002
    Posts
    92

    Re: Hotkey to mark all cells from current to last/first of column ?

    Quote Originally Posted by Special-K View Post
    Down arrow while holding Ctrl-Shift?
    Thanks.
    I know this hotkey, but from what I can gather from the helpfile and my personal tests, this would be doing what I want, except that it *STOPS* at blank cells. So if somewhere in the column, you have blank cells, the selection would not go all the way down (or up), but only so far as a blank cell is found ....

  5. #5
    Registered User
    Join Date
    08-31-2009
    Location
    boarders' paradise
    MS-Off Ver
    Excel 2002
    Posts
    92

    Re: Hotkey to mark all cells from current to last/first of column ?

    Quote Originally Posted by Palmetto View Post
    If by "mark" you mean highlight as in selecting cells, then . . .
    Yes, sorry if that was uncleas, I meant "selecting" indeed.

    Thanks for all your suggestions!

    (Will have press more than once if there are blank rows in between.)
    Well, that's exactly my problem. I was looking for a keyboard shortcut to select:
    Quote Originally Posted by boarders paradise
    all cells from the current one to the last/first of column
    ...., not to the last/first non-blank cell in the column.

    I would need this function for almost all my sheets, and I almost can't imagine that something that basic is not covere by a shortcut (considering some of the very exotic shortcuts there are otherwise .... )

  6. #6
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,441

    Re: Hotkey to mark all cells from current to last/first of column ?

    You'll have to use VBA, something alongs the lines of
    Code:
    Sub Select_Cells()
    
        Dim lrow As Long, lcol As Long, rCell As Range
        
        lrow = Cells(Rows.Count, 1).End(xlUp).Row
        lcol = Cells(1, Columns.Count).End(xlToLeft).Column
        
        With ActiveSheet
            Set rCell = ActiveCell
            Range(rCell, Cells(lrow, lcol)).Select
        End With
    
    End Sub
    Which will select a range of cells begining with the activecell to the last row/column.

    See attached workbook, to which the short cut Ctrl + g was assigned to the macro.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-31-2009
    Location
    boarders' paradise
    MS-Off Ver
    Excel 2002
    Posts
    92

    Re: Hotkey to mark all cells from current to last/first of column ?

    Quote Originally Posted by Palmetto View Post
    See attached workbook, to which the short cut Ctrl + g was assigned to the macro.
    Well, first of all, let me thank you ... I hope you didn't have to create the .xls especially for me ... or if you really did, than at least I hope you are experienced enough, that it was quick and easy for you ... I hope I didn't cause you too much work ...

    I opened the .xls file, but I am not sure if I understand your idea. Because when I click on the button, or when I press CTRL+G, all cells are selected to the lower/right end of the sheet. That's the same as Excel's built-in shortcut CTRL+SHIFT+END, isn't it ?

    I would need to stay in the same column ...

  8. #8
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,441

    Re: Hotkey to mark all cells from current to last/first of column ?

    I would need to stay in the same column ...
    You weren't specific about your requirements, which is why I said "along the lines of . ."

    Use this revised code, which will select all the cells in the column from activecell to the last used row in the column.

    Code:
    Sub Select_Cells()
    
        Dim lrow As Long, lcol As Long, rcell As Range
        
        lrow = Cells(Rows.Count, 1).End(xlUp).Row
        lcol = ActiveCell.Column
        
        With ActiveSheet
            Set rcell = ActiveCell
            Range(rcell, Cells(lrow, lcol)).Select
            On Error Resume Next
        End With
    
    End Sub

  9. #9
    Registered User
    Join Date
    08-31-2009
    Location
    boarders' paradise
    MS-Off Ver
    Excel 2002
    Posts
    92

    Re: Hotkey to mark all cells from current to last/first of column ?

    Perfect !! It works great, thank you so much!

    How would I have to change the macro for it to select all the way down to the last cell, not to the first (which your code does) ?

    When I modify your code like this ...
    Code:
     lrow = Cells(Rows.Count, -1).End(xlDown).Row
    ... I get an error ...
    Last edited by boarders paradise; 08-31-2009 at 07:28 PM.

  10. #10
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,441

    Re: Hotkey to mark all cells from current to last/first of column ?

    How would I have to change the macro for it to select all the way down to the last cell, not to the first (which your code does) ?
    The code as originally given already finds the last used cell in the column.
    So if cell A1000 is the last used cell in column-A and cell A25 is the active cell when you run the macro, the range selected is A25:A1000.

    If A10000 is the last used cell, then it selects A25:A10000.

    What do you mean by "down to the last cell"?

  11. #11
    Registered User
    Join Date
    08-31-2009
    Location
    boarders' paradise
    MS-Off Ver
    Excel 2002
    Posts
    92

    Re: Hotkey to mark all cells from current to last/first of column ?

    When I copy your code exactly as is, the macro selects "up", not "down".
    So for example, ...
    Quote Originally Posted by Palmetto View Post
    So if cell A1000 is the last used cell in column-A and cell A25 is the active cell when you run the macro, the range selected is ...
    A1:A25 for me (and not A25:1000 like you wrote).

    Which is not bad anyway, because I need 2 macros for both directions "up to first cell" and "down to last cell" (in column). So your macro already does "up to first cell" for me .... hence my efforts to modify your code so that it would select downwards from the active cell to the last cell in the column.

    But the modifications I tried (and posted above) resulted in errors (obviously, because I have no clue of VisualBasic ...)

  12. #12
    Registered User
    Join Date
    08-31-2009
    Location
    boarders' paradise
    MS-Off Ver
    Excel 2002
    Posts
    92

    Re: Hotkey to mark all cells from current to last/first of column ?

    Hm ....
    I don't know if you will believe me, but I swear I didn't change anything, but now, your macro "selects down to the last cell", not up to the first cell ...

    Well, anyway, I would need both macros, so how would I have to change the 3rd line of your code to get the other direction ?

  13. #13
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,138

    Re: Hotkey to mark all cells from current to last/first of column ?

    Palmetto's code works for me as advertised.

    Here's another way:
    Code:
    Sub Sel2Top()
        Here2Top(ActiveCell).Select
    End Sub
    
    Sub Sel2Bot()
        Here2Bot(ActiveCell).Select
    End Sub
    
    Function Here2Top(cell As Range) As Range
        Dim rTop As Range
        
        Set Here2Top = cell(1)
        
        With cell.Parent
            Set rTop = .Cells(1, cell.Column)
            If rTop.Value = Empty Then Set rTop = rTop.End(xlDown)
            If rTop.Row < cell.Row Then Set Here2Top = .Range(cell(1), rTop)
        End With
    End Function
    
    Function Here2Bot(cell As Range) As Range
        Dim rBot As Range
        
        Set Here2Bot = cell(1)
        
        With cell.Parent
            Set rBot = .Cells(.Rows.Count, cell.Column)
            If rBot.Value = Empty Then Set rBot = rBot.End(xlUp)
            If rBot.Row > cell.Row Then Set Here2Bot = .Range(cell(1), rBot)
        End With
    End Function
    Last edited by shg; 08-31-2009 at 09:22 PM.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

Thread Information

Users Browsing this Thread

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

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.2.0