Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Active Cell problem

I have a VBA function that is located in several Cells
[=myFunction(dataRange as Range)]. For the function to work during Excel
Recalculation process, I need to now the address that Excel is
recalculating. Say the formula is located in the 12 Cells, A1:B6. As Excel
works through the recalculation, my function needs the know the cell (A1:B6)
Excel is recalculating.

I tried

Set HomeCell = Range(ActiveCell.Address)

With this, I only get the cell where the cursor is located at the time Excel
starts the recalculation.

Thanks for the help


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Active Cell problem

And you're calling the function from a formula in a worksheet cell?

If yes, look at Application.caller

Option Explicit
Function myFunc() As String
myFunc = Application.Caller.Address(external:=True)
End Function



"Bruce A. Julseth" wrote:

I have a VBA function that is located in several Cells
[=myFunction(dataRange as Range)]. For the function to work during Excel
Recalculation process, I need to now the address that Excel is
recalculating. Say the formula is located in the 12 Cells, A1:B6. As Excel
works through the recalculation, my function needs the know the cell (A1:B6)
Excel is recalculating.

I tried

Set HomeCell = Range(ActiveCell.Address)

With this, I only get the cell where the cursor is located at the time Excel
starts the recalculation.

Thanks for the help


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Active Cell problem

Thank you, Thank you.

It worked like a charm..

Thanks again for the response


"Dave Peterson" wrote in message
...
And you're calling the function from a formula in a worksheet cell?

If yes, look at Application.caller

Option Explicit
Function myFunc() As String
myFunc = Application.Caller.Address(external:=True)
End Function



"Bruce A. Julseth" wrote:

I have a VBA function that is located in several Cells
[=myFunction(dataRange as Range)]. For the function to work during Excel
Recalculation process, I need to now the address that Excel is
recalculating. Say the formula is located in the 12 Cells, A1:B6. As
Excel
works through the recalculation, my function needs the know the cell
(A1:B6)
Excel is recalculating.

I tried

Set HomeCell = Range(ActiveCell.Address)

With this, I only get the cell where the cursor is located at the time
Excel
starts the recalculation.

Thanks for the help


--

Dave Peterson



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Active Cell problem

Oops.. Just came across a problem with your code snippit..

I get a variable not defined(external) with Option Explicit set. Turn it off
and it runs..

I guess I turn it off with no problem. Do you have any other suggestion?

"Dave Peterson" wrote in message
...
And you're calling the function from a formula in a worksheet cell?

If yes, look at Application.caller

Option Explicit
Function myFunc() As String
myFunc = Application.Caller.Address(external:=True)
End Function



"Bruce A. Julseth" wrote:

I have a VBA function that is located in several Cells
[=myFunction(dataRange as Range)]. For the function to work during Excel
Recalculation process, I need to now the address that Excel is
recalculating. Say the formula is located in the 12 Cells, A1:B6. As
Excel
works through the recalculation, my function needs the know the cell
(A1:B6)
Excel is recalculating.

I tried

Set HomeCell = Range(ActiveCell.Address)

With this, I only get the cell where the cursor is located at the time
Excel
starts the recalculation.

Thanks for the help


--

Dave Peterson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Active Cell problem

"Option Explicit" at the top of a module means that you want VBA to check to
make sure each variable is declared (using Dim or Const or whatever)...

If you get a warning message that you have a variable that isn't defined, then
you should declare that variable.

Dim myVar as string 'or as long or data or whatever it is.

If you declare all your variables, you won't have to spend much time debugging a
line like:

ctrl = ctr1 + 1

Those two are separate variables--one ends with "ell" and one ends with "one".

At first, you may think that this is just a pain, but you'll soon find out that
it saves much more time than the alternative.

"Bruce A. Julseth" wrote:

Oops.. Just came across a problem with your code snippit..

I get a variable not defined(external) with Option Explicit set. Turn it off
and it runs..

I guess I turn it off with no problem. Do you have any other suggestion?

"Dave Peterson" wrote in message
...
And you're calling the function from a formula in a worksheet cell?

If yes, look at Application.caller

Option Explicit
Function myFunc() As String
myFunc = Application.Caller.Address(external:=True)
End Function



"Bruce A. Julseth" wrote:

I have a VBA function that is located in several Cells
[=myFunction(dataRange as Range)]. For the function to work during Excel
Recalculation process, I need to now the address that Excel is
recalculating. Say the formula is located in the 12 Cells, A1:B6. As
Excel
works through the recalculation, my function needs the know the cell
(A1:B6)
Excel is recalculating.

I tried

Set HomeCell = Range(ActiveCell.Address)

With this, I only get the cell where the cursor is located at the time
Excel
starts the recalculation.

Thanks for the help


--

Dave Peterson


--

Dave Peterson


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
getting the selected range and active cell of a non active worksheetsheet GerryGerry Excel Programming 7 September 23rd 09 05:22 PM
problem with active cell none[_3_] Excel Programming 4 October 4th 07 10:39 AM
Can't get CF to work properly, Active Cell problem? Yogi_Bear_79 Excel Programming 7 June 7th 05 06:52 PM
Excel VBA-use variable in active cell formula problem waveracerr Excel Programming 9 February 6th 04 02:49 PM
Problem with Active Cell Refence patterson_m Excel Programming 1 October 10th 03 06:34 PM


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