Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Using a Custom Function - determining the row that called it

Simple function:

Function AddVisible(iTotal)
' code to add cells value if the column is visible.
End Function

in the Total column, I call this function with:
=AddVisible(SUM(AV3:DB3))

I need to know which row 'called' the function, so that I can check for
the visible status of the column, then grab the value.

Also, very open to any other, simpler ways to accomplish this. I have a
function that looks at todays date (NOW) when opening the Worksheet, and
hides all the columns with old data, and columns with data that is more
than 12 months in the future. I now need to show the totals of this
'subset' of the data, but am really struggling learning how to do this
with VBA. Scoured the Help files, and my two Excel 'Bibles' - obviously
need an Excel Programming book...

Assistance in the meantime much appreciated!

Masa
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using a Custom Function - determining the row that called it

You shouldn't have a Sum function within your call to AddVisible. The
addvisible function should do the summing.

Function AddVisible(iTotal)
Dim rng as Range
set rng = Application.Caller
lRW = rng.row

.. . .
End Function

--
Regards,
Tom Ogilvy



"Masa Ito" wrote in message
48.16...
Simple function:

Function AddVisible(iTotal)
' code to add cells value if the column is visible.
End Function

in the Total column, I call this function with:
=AddVisible(SUM(AV3:DB3))

I need to know which row 'called' the function, so that I can check for
the visible status of the column, then grab the value.

Also, very open to any other, simpler ways to accomplish this. I have a
function that looks at todays date (NOW) when opening the Worksheet, and
hides all the columns with old data, and columns with data that is more
than 12 months in the future. I now need to show the totals of this
'subset' of the data, but am really struggling learning how to do this
with VBA. Scoured the Help files, and my two Excel 'Bibles' - obviously
need an Excel Programming book...

Assistance in the meantime much appreciated!

Masa



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Using a Custom Function - determining the row that called it

Thanks for the reply Tom.

The reason I had the Sum function within the call was so that it would
automatically update when one of the values changed within the range
being added. Is there a proper way to accomplish this?

Also, I searched and could not find what lRW is referring to. I am sure
it will be something stupid that I should be able to think of, but if you
don't mind explaining...

Thanks.
M.I.


"Tom Ogilvy" wrote in news:uB39iC0pEHA.1160
@tk2msftngp13.phx.gbl:

You shouldn't have a Sum function within your call to AddVisible. The
addvisible function should do the summing.

Function AddVisible(iTotal)
Dim rng as Range
set rng = Application.Caller
lRW = rng.row

. . .
End Function


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using a Custom Function - determining the row that called it

lRW was just a Variable of type long to hold the value of the row in which
the function resides - since that was your question.

the sum will pass in the value of all the cells in the specified range,
without consideration of whether they are visible or not.

When you use your addvisible function with the range of cells to consider,
excel will use changes in those cells to determine when to run you
addvisible function to recalculate the sum. What won't trigger it is
unhiding a column, but there isn't a work around for that since that doesn't
trigger a calculate.

--
Regards,
Tom Ogilvy

"Masa Ito" wrote in message
48.16...
Thanks for the reply Tom.

The reason I had the Sum function within the call was so that it would
automatically update when one of the values changed within the range
being added. Is there a proper way to accomplish this?

Also, I searched and could not find what lRW is referring to. I am sure
it will be something stupid that I should be able to think of, but if you
don't mind explaining...

Thanks.
M.I.


"Tom Ogilvy" wrote in news:uB39iC0pEHA.1160
@tk2msftngp13.phx.gbl:

You shouldn't have a Sum function within your call to AddVisible. The
addvisible function should do the summing.

Function AddVisible(iTotal)
Dim rng as Range
set rng = Application.Caller
lRW = rng.row

. . .
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
How do I know which cell a function is called from? Murami Excel Worksheet Functions 3 November 24th 06 02:22 PM
What is this function called?? jPaulB Excel Discussion (Misc queries) 3 August 4th 06 08:33 PM
Function, dont know what its called Michael Excel Worksheet Functions 1 May 8th 06 09:47 PM
Possible to know who has called a function ? Isabelle Robin Excel Programming 3 March 5th 04 12:33 AM
Determining whether function called by Excel or VBA Ryan Poth[_2_] Excel Programming 3 July 17th 03 05:26 AM


All times are GMT +1. The time now is 05:24 PM.

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"