Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,276
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formulas over multiple cells Keith Brown Excel Discussion (Misc queries) 0 November 26th 08 11:48 PM
Multiple IF's Using Formulas from Other Cells cmkbird Excel Worksheet Functions 7 June 26th 08 05:58 PM
Multiple formats in a single cell with multiple formulas Zakhary Excel Worksheet Functions 1 May 2nd 08 12:08 AM
Multiple If/Then formulas in one cell Korwin Excel Discussion (Misc queries) 4 January 29th 08 09:14 PM
If formulas with multiple cells??? Schulzy Excel Discussion (Misc queries) 7 October 7th 07 01:53 PM


All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"