Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default First and Last cell of a named range

Hello,

How do you determine what the first and last cell of a named range and get
its value? Can you use the offset function with this?

--
Thanks in advance,

Steven


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default First and Last cell of a named range

Steven,
If your named range is named "MyRange" then this is one way...
'-------------------------------
Sub GetNamedRangeValues()
Dim x As Long
Dim y As Variant

x = Range("MyRange").Count
y = "Last cell value is " & Range("MyRange")(x).Value
MsgBox y

y = Range("MyRange")(1).Value
MsgBox "First cell value is " & y
End Sub
'-----------------------------------

Regards,
Jim Cone
San Francisco, CA

"Steven K" wrote in message ...
Hello,
How do you determine what the first and last cell of a named range and get
its value? Can you use the offset function with this?
Thanks in advance,
Steven


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default First and Last cell of a named range

Hi Steven,

Assuming that the named range is a single area range:

Sub Tester03()
Dim Rng As Range
Dim FirstCell As Range, LastCell As Range

Set Rng = Range("A1:H2")
Set FirstCell = Rng(1)
Set LastCell = Rng(Rng.Count)

'Return address and values of first and last cells
MsgBox "The first cell (" & FirstCell.Address & ") = " _
& FirstCell.value & vbNewLine & _
"The last cell (" & LastCell.Address _
& ") = " & LastCell.value
End Sub


---
Regards,
Norman



"Steven K" wrote in message
...
Hello,

How do you determine what the first and last cell of a named range and get
its value? Can you use the offset function with this?

--
Thanks in advance,

Steven




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
reference first cell in a named range Robert H Excel Worksheet Functions 3 January 14th 08 07:53 PM
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
named cell range Marilyn Excel Worksheet Functions 2 March 13th 06 07:42 PM
Getting a named range from a cell value Charles Woll Excel Worksheet Functions 2 February 25th 05 03:39 PM


All times are GMT +1. The time now is 07:27 PM.

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"