Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Formula Syntax
Excel 2000
I'm new to using VBA with Excel. What I am trying to do is change the formula in a cell based on which cell is active (has focus) Such As: Private Sub Worksheet_Selection Change( byval target as range) If Target.Address = "$A$1" Then Range("E1") = (B1+C1)/D1 Elseif Target.Address = "$A$2" Then Range("E1") = (B2+C2)/D2 End If The part I'm having problem with is the syntax for the formula: Range("E1") = (B1+C1)/D1 Any help appreciated! Dale |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Formula Syntax
Dale,
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$1" Then Range("E1").Formula = "=(B1+C1)/D1" ElseIf Target.Address = "$A$2" Then Range("E1").Formula = "=(B2+C2)/D2" End If End Sub -- Regards, Soo Cheon Jheong _ _ ^ąŻ^ -- |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Formula Syntax
Hi Dale,
Try this Private Sub Worksheet_Selection Change( byval target as range) If Target.Address = "$A$1" Then Range("E1").Formula = "=(B1+C1)/D1" Elseif Target.Address = "$A$2" Then Range("E1").Formula = "=(B2+C2)/D2" End If -- HTH RP (remove nothere from the email address if mailing direct) "Dale" wrote in message ... Excel 2000 I'm new to using VBA with Excel. What I am trying to do is change the formula in a cell based on which cell is active (has focus) Such As: Private Sub Worksheet_Selection Change( byval target as range) If Target.Address = "$A$1" Then Range("E1") = (B1+C1)/D1 Elseif Target.Address = "$A$2" Then Range("E1") = (B2+C2)/D2 End If The part I'm having problem with is the syntax for the formula: Range("E1") = (B1+C1)/D1 Any help appreciated! Dale |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Formula Syntax
Hi Dale
You're pretty close: Range("E1").Formula = "=(B1+C1)/D1" HTH. Best wishes Harald "Dale" skrev i melding ... Excel 2000 I'm new to using VBA with Excel. What I am trying to do is change the formula in a cell based on which cell is active (has focus) Such As: Private Sub Worksheet_Selection Change( byval target as range) If Target.Address = "$A$1" Then Range("E1") = (B1+C1)/D1 Elseif Target.Address = "$A$2" Then Range("E1") = (B2+C2)/D2 End If The part I'm having problem with is the syntax for the formula: Range("E1") = (B1+C1)/D1 Any help appreciated! Dale |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Formula Syntax
try
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column < 1 Then Exit Sub With Target Range("e1") = (.Offset(0, 1) + .Offset(0, 2)) / .Offset(0, 3) End With End Sub -- Don Guillett SalesAid Software "Dale" wrote in message ... Excel 2000 I'm new to using VBA with Excel. What I am trying to do is change the formula in a cell based on which cell is active (has focus) Such As: Private Sub Worksheet_Selection Change( byval target as range) If Target.Address = "$A$1" Then Range("E1") = (B1+C1)/D1 Elseif Target.Address = "$A$2" Then Range("E1") = (B2+C2)/D2 End If The part I'm having problem with is the syntax for the formula: Range("E1") = (B1+C1)/D1 Any help appreciated! Dale |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Formula Syntax
Just another idea. Not sure if you want to insert a formula, of just the
value. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 1 Then Target.Offset(0, 4).FormulaR1C1 = "=(RC[-3]+RC[-2])/RC[-1]" End If End Sub -- Dana DeLouis Win XP & Office 2003 "Dale" wrote in message ... Excel 2000 I'm new to using VBA with Excel. What I am trying to do is change the formula in a cell based on which cell is active (has focus) Such As: Private Sub Worksheet_Selection Change( byval target as range) If Target.Address = "$A$1" Then Range("E1") = (B1+C1)/D1 Elseif Target.Address = "$A$2" Then Range("E1") = (B2+C2)/D2 End If The part I'm having problem with is the syntax for the formula: Range("E1") = (B1+C1)/D1 Any help appreciated! Dale |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formula syntax | Excel Discussion (Misc queries) | |||
formula syntax. | Excel Discussion (Misc queries) | |||
Syntax of formula | Excel Worksheet Functions | |||
Formula Syntax | Excel Worksheet Functions | |||
Formula syntax {;;;} | Excel Worksheet Functions |