Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Multiple cell formulas in different cells
I would like to use a pull down menu to control the formulas in different
cells. For example if the pulldown is set to A then the formula in cells are one thing. If set to B then the formula in that cell would change to something else. I have though of using if statements, but this gets messy. Do I need to get in to macro writing? I am looking for something simple. Cheers |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Multiple cell formulas in different cells
Hi,
Could you be more specific, which are the formulas, a sample will help "JulianP" wrote: I would like to use a pull down menu to control the formulas in different cells. For example if the pulldown is set to A then the formula in cells are one thing. If set to B then the formula in that cell would change to something else. I have though of using if statements, but this gets messy. Do I need to get in to macro writing? I am looking for something simple. Cheers |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Multiple cell formulas in different cells
CHOOSE ?
LOOKUP ? -- David Biddulph "JulianP" wrote in message ... I would like to use a pull down menu to control the formulas in different cells. For example if the pulldown is set to A then the formula in cells are one thing. If set to B then the formula in that cell would change to something else. I have though of using if statements, but this gets messy. Do I need to get in to macro writing? I am looking for something simple. Cheers |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Multiple cell formulas in different cells
Say we have a Data Validation drop-down in A1 that selects from:
a,b,c,d and we want to make the formula in A4: =A1+A2 or =A1-A2 or =A1*A2 or =A1/A2 Insert the following macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Dim a1 As Range, t As Range, v As String Dim formu As String Set a1 = Range("A1") Set t = Target If Intersect(a1, t) Is Nothing Then Exit Sub v = t.Value If v = "a" Then formu = "=A2+A3" If v = "b" Then formu = "=A2-A3" If v = "c" Then formu = "=A2*A3" If v = "d" Then formu = "=A2/A3" Application.EnableEvents = False Range("A4").Formula = formu Application.EnableEvents = True End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200859 "JulianP" wrote: I would like to use a pull down menu to control the formulas in different cells. For example if the pulldown is set to A then the formula in cells are one thing. If set to B then the formula in that cell would change to something else. I have though of using if statements, but this gets messy. Do I need to get in to macro writing? I am looking for something simple. Cheers |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Multiple cell formulas in different cells
If number of options is limited, why not simply =IF(A1="X",formula1,formula2)
or =IF(A1="X",formula1,IF(A2="Y",formula2, ...)) etc. Regards, Stefi €˛Gary''s Student€¯ ezt Ć*rta: Say we have a Data Validation drop-down in A1 that selects from: a,b,c,d and we want to make the formula in A4: =A1+A2 or =A1-A2 or =A1*A2 or =A1/A2 Insert the following macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Dim a1 As Range, t As Range, v As String Dim formu As String Set a1 = Range("A1") Set t = Target If Intersect(a1, t) Is Nothing Then Exit Sub v = t.Value If v = "a" Then formu = "=A2+A3" If v = "b" Then formu = "=A2-A3" If v = "c" Then formu = "=A2*A3" If v = "d" Then formu = "=A2/A3" Application.EnableEvents = False Range("A4").Formula = formu Application.EnableEvents = True End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200859 "JulianP" wrote: I would like to use a pull down menu to control the formulas in different cells. For example if the pulldown is set to A then the formula in cells are one thing. If set to B then the formula in that cell would change to something else. I have though of using if statements, but this gets messy. Do I need to get in to macro writing? I am looking for something simple. Cheers |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Multiple cell formulas in different cells
The OP specifically asked for an alternative to IF statements.
I agree that your suggestion is the better solution. Even if the number of options was very large, it would be better to store all the formulas in a table and then use VLOOKUP() -- Gary''s Student - gsnu200859 "Stefi" wrote: If number of options is limited, why not simply =IF(A1="X",formula1,formula2) or =IF(A1="X",formula1,IF(A2="Y",formula2, ...)) etc. Regards, Stefi €˛Gary''s Student€¯ ezt Ć*rta: Say we have a Data Validation drop-down in A1 that selects from: a,b,c,d and we want to make the formula in A4: =A1+A2 or =A1-A2 or =A1*A2 or =A1/A2 Insert the following macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Dim a1 As Range, t As Range, v As String Dim formu As String Set a1 = Range("A1") Set t = Target If Intersect(a1, t) Is Nothing Then Exit Sub v = t.Value If v = "a" Then formu = "=A2+A3" If v = "b" Then formu = "=A2-A3" If v = "c" Then formu = "=A2*A3" If v = "d" Then formu = "=A2/A3" Application.EnableEvents = False Range("A4").Formula = formu Application.EnableEvents = True End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200859 "JulianP" wrote: I would like to use a pull down menu to control the formulas in different cells. For example if the pulldown is set to A then the formula in cells are one thing. If set to B then the formula in that cell would change to something else. I have though of using if statements, but this gets messy. Do I need to get in to macro writing? I am looking for something simple. Cheers |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Multiple cell formulas in different cells
Yes, I didn't notice that he wants a pulldown of formulae! Maybe he doesn't
know other techniques like embedded IFs, VLOOKUP, etc. Regards, Stefi €˛Gary''s Student€¯ ezt Ć*rta: The OP specifically asked for an alternative to IF statements. I agree that your suggestion is the better solution. Even if the number of options was very large, it would be better to store all the formulas in a table and then use VLOOKUP() -- Gary''s Student - gsnu200859 "Stefi" wrote: If number of options is limited, why not simply =IF(A1="X",formula1,formula2) or =IF(A1="X",formula1,IF(A2="Y",formula2, ...)) etc. Regards, Stefi €˛Gary''s Student€¯ ezt Ć*rta: Say we have a Data Validation drop-down in A1 that selects from: a,b,c,d and we want to make the formula in A4: =A1+A2 or =A1-A2 or =A1*A2 or =A1/A2 Insert the following macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Dim a1 As Range, t As Range, v As String Dim formu As String Set a1 = Range("A1") Set t = Target If Intersect(a1, t) Is Nothing Then Exit Sub v = t.Value If v = "a" Then formu = "=A2+A3" If v = "b" Then formu = "=A2-A3" If v = "c" Then formu = "=A2*A3" If v = "d" Then formu = "=A2/A3" Application.EnableEvents = False Range("A4").Formula = formu Application.EnableEvents = True End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200859 "JulianP" wrote: I would like to use a pull down menu to control the formulas in different cells. For example if the pulldown is set to A then the formula in cells are one thing. If set to B then the formula in that cell would change to something else. I have though of using if statements, but this gets messy. Do I need to get in to macro writing? I am looking for something simple. Cheers |
#8
Posted to microsoft.public.excel.misc
|
|||
|
|||
Multiple cell formulas in different cells
Thank you. This works for me because I have different formulars for several
cells that depend on the selected option. I will give it a shot. Cheers "Gary''s Student" wrote: Say we have a Data Validation drop-down in A1 that selects from: a,b,c,d and we want to make the formula in A4: =A1+A2 or =A1-A2 or =A1*A2 or =A1/A2 Insert the following macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Dim a1 As Range, t As Range, v As String Dim formu As String Set a1 = Range("A1") Set t = Target If Intersect(a1, t) Is Nothing Then Exit Sub v = t.Value If v = "a" Then formu = "=A2+A3" If v = "b" Then formu = "=A2-A3" If v = "c" Then formu = "=A2*A3" If v = "d" Then formu = "=A2/A3" Application.EnableEvents = False Range("A4").Formula = formu Application.EnableEvents = True End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200859 "JulianP" wrote: I would like to use a pull down menu to control the formulas in different cells. For example if the pulldown is set to A then the formula in cells are one thing. If set to B then the formula in that cell would change to something else. I have though of using if statements, but this gets messy. Do I need to get in to macro writing? I am looking for something simple. Cheers |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formulas over multiple cells | Excel Discussion (Misc queries) | |||
Multiple IF's Using Formulas from Other Cells | Excel Worksheet Functions | |||
Multiple formats in a single cell with multiple formulas | Excel Worksheet Functions | |||
Multiple If/Then formulas in one cell | Excel Discussion (Misc queries) | |||
If formulas with multiple cells??? | Excel Discussion (Misc queries) |