#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Offset

I am trying (within a macro) to create a subset range
that only includes the last 36 values of my input range.
I think that using the offset function is the way to do
this but am not sure.

For example, if the function is =newfunc(A1:A250), then
I want the subset to be the last 36 values. So if every
cell has a value in it then the subset would refer to
A215:A250. However, if the last cell with a value in it
was A172, then the subset would be cells A137:A172.

Thanks for the help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Offset

Hi
if you have no blank rows in between try something like
sub foo()
dim lastrow as long
Dim firstrow as long
Dim rng as range

with activesheet
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
firstrow =application.max(lastrow-11,1)
set rng = .range("A" & firstrow & ":A" & lastrow)
msgbox rng.address
end with
end sub


--
Regards
Frank Kabel
Frankfurt, Germany


Alex wrote:
I am trying (within a macro) to create a subset range
that only includes the last 36 values of my input range.
I think that using the offset function is the way to do
this but am not sure.

For example, if the function is =newfunc(A1:A250), then
I want the subset to be the last 36 values. So if every
cell has a value in it then the subset would refer to
A215:A250. However, if the last cell with a value in it
was A172, then the subset would be cells A137:A172.

Thanks for the help.

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
OFFSET Jose Mourinho Excel Worksheet Functions 1 December 23rd 09 01:26 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
OFFSET PLEASE HELP! HERNAN Excel Discussion (Misc queries) 6 October 27th 06 10:17 PM
Offset Brian Excel Worksheet Functions 6 April 7th 06 12:33 PM
offset T.K Kullervo Excel Programming 1 August 26th 03 02:20 PM


All times are GMT +1. The time now is 03:02 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"