+ Reply to Thread
Results 1 to 5 of 5

Ctrl+End with VBA

  1. #1
    Dave B
    Guest

    Ctrl+End with VBA

    How can I use VBA to find out which cell Excel would move to if I pressed
    Ctrl+End (i.e. how do I find the last cell in the used range using VBA)?
    Thanks.



  2. #2
    Forum Contributor
    Join Date
    06-02-2005
    Location
    India
    MS-Off Ver
    2007
    Posts
    138
    By pressing CTRL + End key excel takes you to last used range of your active sheet.

    Through vba, try this...

    Please Login or Register  to view this content.
    Last edited by ilyaskazi; 10-19-2005 at 11:39 PM.

  3. #3
    Norman Jones
    Guest

    Re: Ctrl+End with VBA

    Hi Dave B,

    > how do I find the last cell in the used range using VBA)?


    Try:

    Dim rng As Range

    Set rng = Cells.SpecialCells(xlCellTypeLastCell)

    Note that the last cell in the used range may not be populated.

    ---
    Regards,
    Norman



    "Dave B" <[email protected]> wrote in message
    news:%[email protected]...
    > How can I use VBA to find out which cell Excel would move to if I pressed
    > Ctrl+End (i.e. how do I find the last cell in the used range using VBA)?
    > Thanks.
    >
    >




  4. #4
    Paul D. Simon
    Guest

    Re: Ctrl+End with VBA

    I believe this 1-line code should do what you're looking for.

    ActiveCell.SpecialCells(xlLastCell).Select


    or as an alternative, this 1 line should work also.

    ActiveCell.SpecialCells(xlCellTypeLastCell).Select


  5. #5
    Registered User
    Join Date
    06-16-2014
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    1

    Re: Ctrl+End with VBA

    ilyaskazi's anwer is just fine. Thanks a lot.
    The others too. Just replace ".Select" by ".Address" to have the cell.

    MsgBox (ActiveCell.SpecialCells(xlCellTypeLastCell).Address)
    MsgBox (ActiveCell.SpecialCells(xlLastCell).Address)

    And if you want only the row
    MsgBox ("La ligne active est : " & ActiveCell.SpecialCells(xlLastCell).Row)
    Usefull when you want to make a loop until "end of file".


+ 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