LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Activate last cell in selected range - an example

No question here, just a procedure for the archive.

Search critera: activate the last cell in a selection
select last cell in range
select last cell in selection
activate last cell in range


Sub SelectActivateLastCellInSelectedRange()
'Activates the last cell in the selected range but keeps the
'same range selected


Dim LastRow As Variant
Dim LastCol As Variant
Dim TempRow As Variant
Dim TempCol As Variant
Dim LastCell As Range
Dim A As Range


LastRow = 1
LastCol = 1
ActiveWorkbook.Activate
For Each A In Selection.Areas
TempRow = A.Range("A1").Offset(A.Rows.Count - 1, 0).Row
If TempRow LastRow Then LastRow = TempRow
TempCol = A.Range("A1").Offset(0, A.Columns.Count - 1).Column
If TempCol LastCol Then LastCol = TempCol
Next A
Set LastCell = Cells(LastRow, LastCol)
LastCell.Activate


End Sub
 
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
Insert selected cell value into next cell in range that is empty Guy[_2_] Excel Worksheet Functions 6 January 3rd 09 10:08 PM
Selecting the value from a randomly selected cell out of a range Steve W. Excel Discussion (Misc queries) 1 June 3rd 08 06:27 PM
How to get Total of Colored Cell in Selected Range Qazi Ahmad Excel Discussion (Misc queries) 1 June 22nd 07 04:17 PM
Activate cell at end of range G Setting up and Configuration of Excel 2 November 22nd 05 04:10 PM
Activate button when row selected. Johnnyb Excel Programming 3 August 17th 04 01:51 PM


All times are GMT +1. The time now is 11:30 PM.

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

About Us

"It's about Microsoft Excel"