ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do i start Macros using IF statements? (https://www.excelbanter.com/excel-discussion-misc-queries/41467-how-do-i-start-macros-using-if-statements.html)

xXx Katie xXx

How do i start Macros using IF statements?
 
How can i use an IF statement to start a macro using data validation to get a
list in a cell if the previous cell equals a specific word.

Eg. IF C1 = "Bedroom" then it will trigger the macro to use data validation
in the next cell to display a list of diffent number of bedrooms which the
user can then choose.

Gary's Student

You need a worksheet change event macro to monitor C1 and respond accordingly.

See:

http://www.mvps.org/dmcritchie/excel/event.htm

for complete details. Good Luck
--
Gary's Student


"xXx Katie xXx" wrote:

How can i use an IF statement to start a macro using data validation to get a
list in a cell if the previous cell equals a specific word.

Eg. IF C1 = "Bedroom" then it will trigger the macro to use data validation
in the next cell to display a list of diffent number of bedrooms which the
user can then choose.


Bill Martin -- (Remove NOSPAM from address)

xXx Katie xXx wrote:
How can i use an IF statement to start a macro using data validation to get a
list in a cell if the previous cell equals a specific word.

Eg. IF C1 = "Bedroom" then it will trigger the macro to use data validation
in the next cell to display a list of diffent number of bedrooms which the
user can then choose.



I'm not aware of a way to directly do what you want -- perhaps some else here
will. However....

You can call functions from normal Excel formulas. e.g.:

If(C1="Bedroom",YourCustomFunction(A1:B2),"no activity")

Perhaps you can use a VBA custom function to do what you want? The primary
difference is that a macro can reach out and touch anything anywhere. A
function can only touch cells which are included in its parameter list when you
call it.

Good luck...

Bill


All times are GMT +1. The time now is 04:52 PM.

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