Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default dynamic range without using OFFSET()

I've seen a number of posts which use the OFFSET() function to create
a dynamic range. This is neat but I thought I could do it better by
using my own function (see below). However, I seem to be unable to
plot this range on a chart in the same way that I could plot a dyn.
range creating using the OFFSET function. Does anyone know why this
is or whether there is a work-around?

Thanks,
Andrew


Public Function DYNRANGEV(FirstCell As Range) As Range
Set DYNRANGEV = FirstCell.Parent.Range(FirstCell.Address & ":" & _
FirstCell.End(xlDown).Address)
End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default dynamic range without using OFFSET()

I think you are geting confused by a dynamic range as set up in an
Excel Worksheet and that set up in VB code. The former is a *string*
preceded by an '=', and can only use worksheet functions. It will not
recognise .End().

Your function can only be used within VB. Here is a way of resetting
the range using VB based on your requirement :-

'--------------------------------------
Sub ChangeNamedRange()
Dim RangeFormula As String
Dim RangeName As String
'----------------------
RangeName = "TestRange"
RangeFormula = "='" & ActiveSheet.Name & "'!" _
& ActiveCell.Address & ":" _
& ActiveCell.End(xlDown).Address
'- add name to collection
ActiveWorkbook.Names.Add Name:=RangeName, RefersTo:=RangeFormula
'- test
ActiveSheet.Range(RangeName).Select
End Sub
'--------------------------------------


Regards
BrianB
==================================



Regards
BrianB
=============================





(Andrew) wrote in message . com...
I've seen a number of posts which use the OFFSET() function to create
a dynamic range. This is neat but I thought I could do it better by
using my own function (see below). However, I seem to be unable to
plot this range on a chart in the same way that I could plot a dyn.
range creating using the OFFSET function. Does anyone know why this
is or whether there is a work-around?

Thanks,
Andrew


Public Function DYNRANGEV(FirstCell As Range) As Range
Set DYNRANGEV = FirstCell.Parent.Range(FirstCell.Address & ":" & _
FirstCell.End(xlDown).Address)
End Function

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
Dynamic Range for Offset VBApprentice :) Excel Worksheet Functions 8 January 13th 10 05:27 PM
Dynamic Range in Offset Help Request VBApprentice :) Excel Worksheet Functions 1 January 12th 10 03:49 AM
Dynamic Range Using INDEX instead of Offset [email protected] Excel Discussion (Misc queries) 4 September 19th 07 06:16 AM
Offset, Dynamic range, Countif Bryce Excel Discussion (Misc queries) 3 October 26th 05 12:58 PM
dynamic range / offset Jeff Excel Worksheet Functions 2 February 23rd 05 03:39 PM


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