Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Query -
Hi I have this small query.
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 wrote in reponse (BUT IS THIS IS THE ONLY OPTION -i want to try and keep the formula as simple as possible other people will be using it) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Query -
Hi James:
You should pass the lookup table to the function as a parameter, e.g: '============= Function FindOldNominal(NomCode, Table As Range) FindOldNominal = WorksheetFunction. _ VLookup(NomCode, Table, 2, False) End Function '<<============= Alternatively, and very much as a second best option, Insert the line: Application.Volatile at the head of your function. This will ensure that the function will update every time that the worksheet is recalculated. --- Regards, Norman "James Cornthwaite" wrote in message ... Hi I have this small query. 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 wrote in reponse (BUT IS THIS IS THE ONLY OPTION -i want to try and keep the formula as simple as possible other people will be using it) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Query -
or just use:
FindOldNominal = Application.WorksheetFunction.VLookup(NomCode, range("IMPORTRANGE"),5,false) all the best Jason |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Query -
thats great thanks
"WhytheQ" wrote in message oups.com... or just use: FindOldNominal = Application.WorksheetFunction.VLookup(NomCode, range("IMPORTRANGE"),5,false) all the best Jason |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Query -
or just use:
FindOldNominal = Application.WorksheetFunction.VLookup(NomCode, range("IMPORTRANGE"),5,false) What's great about it? Could you clarify. I don't see any difference from what you had - adding Application adds nothing? Are you saying that makes the formula update for a change in the lookup range? It certainly didn't for me. -- Regards, Tom Ogilvy "James Cornthwaite" wrote in message ... thats great thanks "WhytheQ" wrote in message oups.com... or just use: FindOldNominal = Application.WorksheetFunction.VLookup(NomCode, range("IMPORTRANGE"),5,false) all the best Jason |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Query | Excel Discussion (Misc queries) | |||
another macro query - deleting a worksheet within a query | Excel Discussion (Misc queries) | |||
New Web Query Macro | Excel Programming | |||
NEW WEB QUERY MACRO | Setting up and Configuration of Excel | |||
Query during macro run | Excel Programming |