Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 16th, 2004, 10:22 AM
Authorized User
 
Join Date: Jun 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default CurrentArray Range in Formula

Hi All,

This may fall under the MSKB213199, but I wanted to see if anybody knew of a way to do this.

We have a function that looks through the worksheet for all occurrences of that function (grouping the parameters of that function for an OPC call).

I have no trouble finding the cells that contain the function with that name. However, what I want to do is find the selected range of each of those function calls (top left and bottom right cells).

I tried to use the CurrentArray property of the cell that is found to contain the function, but it only gives me a range containing that cell, not the entire range.

For example, if the function is found in an array from B2:D3, the CurrentArray.Rows.Count = 1 (same for columns). That gives an offset of (0, 0), which makes the first cell = last cell = B2.

Any ideas? I am trying to get around the problem with assuming the shape and size of the formula array.

Thanks,
Paul
 
Old October 5th, 2004, 03:53 AM
Authorized User
 
Join Date: Aug 2004
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure exactly what you are trying to do. Perhaps a couple of comments might help.
1. CurrentArray refers to Array Formulas.
2. The MSKB article really just says that we cannot change contents of a sheet from a UDF (just the cell that contains it).
3. A cell formula at base level is just a string, so you can examine the contents of the formula to get the range it refers to. eg.
Code:
Sub test()
    Dim MyString As String
    MyString = Range("A1").Formula
    MsgBox (MyString)
End Sub
4. If you are trying to get a range that consists of the cells containing the formula you could add each cell reference as it is found by using the Union method.

-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with formula 2 Juan0214 Access 3 July 10th, 2008 06:52 PM
formula sinha Crystal Reports 1 October 26th, 2005 12:53 PM
Excel Formula End Range Changes when Macro Is Run maaron Excel VBA 0 October 11th, 2005 10:56 AM
Excel Formula End Range Changes when Macro Is Run maaron Beginning VB 6 0 October 11th, 2005 10:33 AM
Error setting Formula Array property for a Range arnowitz Excel VBA 2 February 5th, 2004 02:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.