ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   My first macro, uses Vlookup but doesnt update unless hit enter (https://www.excelbanter.com/excel-worksheet-functions/90419-my-first-macro-uses-vlookup-but-doesnt-update-unless-hit-enter.html)

James Cornthwaite

My first macro, uses Vlookup but doesnt update unless hit enter
 
I have written the macro (my first!) as below

Function FindOldNominal(NomCode)

FindOldNominal = WorksheetFunction.VLookup(NomCode, range("IMPORTRANGE"), 5,
false)
End Function




This works fine... except..


If I alter the value in the defined range "ImportRange" say from 10 to 20
at nomcode X then

FindOldNominal(X) still says 10, unless I go into the cell where the
formula call of '=FindOldNominal(X)' is and press enter again.

My question is I would like it to update it self automatically like the sum
function "=sum" does. Is there a reason why this macro isn't or are all
macros like this.
Is there a way round it if this is the case.


Many thanks in anticipation

James



Bob Phillips

My first macro, uses Vlookup but doesnt update unless hit enter
 
see response in programming

--
HTH

Bob Phillips

(replace xxxx in email address with googlemail if mailing direct)

"James Cornthwaite" wrote in message
...
I have written the macro (my first!) as below

Function FindOldNominal(NomCode)

FindOldNominal = WorksheetFunction.VLookup(NomCode, range("IMPORTRANGE"),

5,
false)
End Function




This works fine... except..


If I alter the value in the defined range "ImportRange" say from 10 to 20
at nomcode X then

FindOldNominal(X) still says 10, unless I go into the cell where the
formula call of '=FindOldNominal(X)' is and press enter again.

My question is I would like it to update it self automatically like the

sum
function "=sum" does. Is there a reason why this macro isn't or are all
macros like this.
Is there a way round it if this is the case.


Many thanks in anticipation

James






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

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