Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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" wrote in message
...
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.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Ctrl+End with VBA


By pressing CTRL + End key excel takes you to last used range of you
active sheet.

Through vba, try this...


Code
-------------------

Sub Select_CTRL_END()
Dim myCol As Integer, myRow As Long
myCol = ActiveSheet.UsedRange.Columns.count
myRow = ActiveSheet.UsedRange.Rows.count

ActiveSheet.Cells(myRow, myCol).Select 'optional to select

'Find your last cell
MsgBox ActiveSheet.Cells(myRow, myCol).Address(False, False)

End Sub

-------------------

--
ilyaskaz
-----------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...fo&userid=2396
View this thread: http://www.excelforum.com/showthread.php?threadid=47777

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a difference between CTRL+D and CTRL+" (quotation marks) AKMMS Excel Discussion (Misc queries) 2 March 22nd 10 07:43 PM
How to make Ctrl-C, ctrl-V work in Office 2007 hj Excel Discussion (Misc queries) 1 June 23rd 09 01:09 PM
Excel 2007: Ctrl+PgUp or Ctrl+PgDn with Protected Sheets DrDave Excel Discussion (Misc queries) 1 July 28th 08 04:12 AM
Redefining the Ctrl [ and Ctrl ]s short cut with OnKey? John Wirt[_5_] Excel Programming 6 January 24th 05 05:46 AM
Disabling Ctrl-PgUp and Ctrl-PgDn K.A. Hueston Excel Programming 3 October 9th 04 12:31 AM


All times are GMT +1. The time now is 12:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"