Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / March 2008

Tip: Looking for answers? Try searching our database.

Macro code for END + Arrow key movement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
skiing - 19 Mar 2008 22:18 GMT
When recording a macro - the absolute cell addresses are referenced as
an end result of my using the END & UPARROW (DOWN ARROW, etc...).  In
an unknown range of data I would like to use the movement keys define
my print range.  My method is to go to column D - press the END + DOWN
ARROW which moves me to the last used cell in column D.  Hold the
Shift key and press CTRL HOME - which moves me back to B2 (due to
frozen titles) - then I press the UP ARROW and next the LEFT ARROW KEY
( to include row 1 and column A). Then set the print range.  Can
someone advise as to macro code for this procedure?

(Many different users use a copy of this excel file - often they move
to other columns, etc.. the CTRL END ( which should take you to the
last used cell in that worksheet) does not always take you to the last
cell in column D due to their moving around. The print range should
not exceed past column D and the last used row).
Gord Dibben - 19 Mar 2008 22:38 GMT
Sub selectrange2()
Dim rng As Range
   Set rng = Range(Range("A1"), Cells(Rows.Count, "D").End(xlUp))
      MsgBox rng.Address
   'rng.PrintOut
End Sub

Or a two-liner

Sub selectrange2()
          Range(Range("A1"), Cells(Rows.Count, "D").End(xlUp)).Select
          Selection.PrintOut
End Sub

Gord Dibben  MS Excel MVP

>When recording a macro - the absolute cell addresses are referenced as
>an end result of my using the END & UPARROW (DOWN ARROW, etc...).  In
[quoted text clipped - 11 lines]
>cell in column D due to their moving around. The print range should
>not exceed past column D and the last used row).

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.