ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   forcing UDF to run (https://www.excelbanter.com/excel-worksheet-functions/62298-forcing-udf-run.html)

Stefi

forcing UDF to run
 
Hi All,

I have a very simple UDF returning the address of the selected cell:

Public Function AktCell() As String
AktCell = ActiveCell.Address(False, False)
End Function

It works fine when I newly insert it in a cell, but doesn't refresh the cell
when I select another cell despite I have a Calculation line a
Selection_change event!

How can I force the UDF to run when selecting a new cell?

Thanks,
Stefi


Peo Sjoblom

forcing UDF to run
 
Add this

application.volatile

--
Regards,

Peo Sjoblom

(No private emails please)


"Stefi" wrote in message
...
Hi All,

I have a very simple UDF returning the address of the selected cell:

Public Function AktCell() As String
AktCell = ActiveCell.Address(False, False)
End Function

It works fine when I newly insert it in a cell, but doesn't refresh the
cell
when I select another cell despite I have a Calculation line a
Selection_change event!

How can I force the UDF to run when selecting a new cell?

Thanks,
Stefi



Don Guillett

forcing UDF to run
 
as the first line in the function

--
Don Guillett
SalesAid Software

"Peo Sjoblom" wrote in message
...
Add this

application.volatile

--
Regards,

Peo Sjoblom

(No private emails please)


"Stefi" wrote in message
...
Hi All,

I have a very simple UDF returning the address of the selected cell:

Public Function AktCell() As String
AktCell = ActiveCell.Address(False, False)
End Function

It works fine when I newly insert it in a cell, but doesn't refresh the
cell
when I select another cell despite I have a Calculation line a
Selection_change event!

How can I force the UDF to run when selecting a new cell?

Thanks,
Stefi





Bob Phillips

forcing UDF to run
 
There is nothing in the function that forces a recalculation of the
function. Even if you put Application.Volatile in there it will only
recalculate when you have something that forces a sheet
recalculation.selecting another cell does not do that

You can do it with an event procedure


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Range("showactive").Value = Target.Address(False, False)
End Sub

where showactive is the name of a cell to show the active cell address

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Stefi" wrote in message
...
Hi All,

I have a very simple UDF returning the address of the selected cell:

Public Function AktCell() As String
AktCell = ActiveCell.Address(False, False)
End Function

It works fine when I newly insert it in a cell, but doesn't refresh the

cell
when I select another cell despite I have a Calculation line a
Selection_change event!

How can I force the UDF to run when selecting a new cell?

Thanks,
Stefi




Stefi

forcing UDF to run
 
Fine, it works, thanks!

Regards,
Stefi


€˛Peo Sjoblom€¯ ezt Ć*rta:

Add this

application.volatile

--
Regards,

Peo Sjoblom

(No private emails please)


"Stefi" wrote in message
...
Hi All,

I have a very simple UDF returning the address of the selected cell:

Public Function AktCell() As String
AktCell = ActiveCell.Address(False, False)
End Function

It works fine when I newly insert it in a cell, but doesn't refresh the
cell
when I select another cell despite I have a Calculation line a
Selection_change event!

How can I force the UDF to run when selecting a new cell?

Thanks,
Stefi





All times are GMT +1. The time now is 05:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com