#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Range to Last Cell

I am writing an Excel 2002 template and wish to use VBA to 'highlight' a
range from A3 to the last cell. The row of the last cell will vary but will
always be in column N.

My VBA knowledge is limited. I have tried and failed with
Range ("A3").SpecialCells(xlLastCell).Activate
and I am not sure if I need 'Select' or 'Activate' to 'highlight' the range.

When complete, the worksheet view should show A1 as the top left (home) cell
rather than (for example) N999 at the bottom right.

Thanks in anticipation.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Range to Last Cell

Hi,

With the usual caveat that it is extremely unlikely you need to select this
range to do what you want to do

Dim LastRow As Long
Set sht = Sheets("Sheet1")
LastRow = sht.Cells(Cells.Rows.Count, "N").End(xlUp).Row
sht.Range("A3:N" & LastRow).Select
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Grey Old Man" wrote:

I am writing an Excel 2002 template and wish to use VBA to 'highlight' a
range from A3 to the last cell. The row of the last cell will vary but will
always be in column N.

My VBA knowledge is limited. I have tried and failed with
Range ("A3").SpecialCells(xlLastCell).Activate
and I am not sure if I need 'Select' or 'Activate' to 'highlight' the range.

When complete, the worksheet view should show A1 as the top left (home) cell
rather than (for example) N999 at the bottom right.

Thanks in anticipation.


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
Find Last cell in Range when range is date format default105 Excel Discussion (Misc queries) 5 July 7th 09 03:11 PM
RANGE EXCEL copy cell that meets criteria in a range confused Excel Worksheet Functions 3 March 27th 08 01:41 PM
copy range and paste into every 3rd cell of new range thomsonpa New Users to Excel 4 December 3rd 07 01:47 PM
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM


All times are GMT +1. The time now is 09:06 AM.

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"