+ Reply to Thread
Results 1 to 6 of 6

Current Region through a function

  1. #1
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Current Region through a function

    I am trying to get the address of Current Region through a Function call. The function only returns the address of the cell, not current region. Isn't it possible to use Current Region within a function? It works for a Subroutine.

    I have attached the examples in a file.
    Attached Files Attached Files

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Current Region through a function

    No - this will not work in a UDF. It is like SpecialCells or CurrentArray.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Current Region through a function

    what do you need it for?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Current Region through a function

    Quote Originally Posted by martindwilson View Post
    what do you need it for?
    I wanted to send only one cell in a header row to a table as argument and inside the function determine the complete table range from CurrentRegion. I don't want to send the complete table range as argument into the function. For the moment I use Range.End() inside the function and it works but no cell is allowed to be empty in the column I use to pick complete table range. Using CurrentRegion should solve this issue.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Current Region through a function

    If you do that, Excel will see no dependency on the body of the table, and so will not recalculate when something changes. UDFs should be passed all of the ranges they have dependencies on.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Current Region through a function

    OK. You're right. I have written a lot of functions which are called from subroutines inside VBA. I wanted them also to work from a spreadheet function. However, I will rewrite them some and pass the complete table range calling them from spreadsheet function. I could have used Application.Volatile inside the function to calculate recalculate the function each time a cell changes. But to many of these will slow down the project.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Using current.region less 1 column
    By duugg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-31-2009, 04:54 PM
  2. Replies: 1
    Last Post: 10-04-2007, 12:04 PM
  3. current region = name
    By by1612 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-27-2007, 06:58 PM
  4. looping through current region
    By buffyslay in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2006, 02:10 PM
  5. Assigning name to current region
    By KDJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-21-2005, 12:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1