ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   newbie range question (https://www.excelbanter.com/excel-programming/354642-newbie-range-question.html)

[email protected]

newbie range question
 
Hello,

I am new to vba and want to write a function that takes a range of
cells as the argument. In VBA I want to be able to mostly access the
value in the first cell, and the value in the last cell. Do I want to
use the 'range' type for this? By playing around, it seems ".value"
gives me the value in the first cell. Is there a way to get the value
in the last cell of the range?

thanks for any help,
scott


Jim Thomlinson[_5_]

newbie range question
 
A range object should work for you. What you need is to access the item to
select the appropraite cells, something like this...

dim rng as Range

set rng = Sheets("Sheet1").Range("A1:C10")

with rng
msgbox .value 'This one you know about
msgbox .item(.count).value 'The last item in the range
end with
--
HTH...

Jim Thomlinson


" wrote:

Hello,

I am new to vba and want to write a function that takes a range of
cells as the argument. In VBA I want to be able to mostly access the
value in the first cell, and the value in the last cell. Do I want to
use the 'range' type for this? By playing around, it seems ".value"
gives me the value in the first cell. Is there a way to get the value
in the last cell of the range?

thanks for any help,
scott




All times are GMT +1. The time now is 02:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com