Hello all,
I'm trying to insert an algebraic formula into a Range of cells depending on the value of cell("F1"). For instance if cell("F1")=1 then I want to use formula A, if cell("F1")=2 then I want to use formula B, and so on. Currently I have a simple Function set up with If/Then statements, but whenever I change cell("F1") it fails to implement the new formula. Currently the code is in "module 2" I think that I probably need to use
but am unsure as to how, since I can't specify which function to use. My code is as follows.
I am a novice programmer, so if you could be as simple and specific as possible i would greatly appreciate it.
Thank You in Advance,
Andy
I'm trying to insert an algebraic formula into a Range of cells depending on the value of cell("F1"). For instance if cell("F1")=1 then I want to use formula A, if cell("F1")=2 then I want to use formula B, and so on. Currently I have a simple Function set up with If/Then statements, but whenever I change cell("F1") it fails to implement the new formula. Currently the code is in "module 2" I think that I probably need to use
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("B4")) Is Nothing Then
If Target.Value >= 1 Then
Application.Run "function"
End If
End If
End Sub
but am unsure as to how, since I can't specify which function to use. My code is as follows.
Code:
Function InsertFormula()
If Range("F1") = 1 Then
Worksheets("Simethicone Calculation").Range("G12:G21").Formula = "=(((E12*$B$6*30)/($B$7*40*C12))*D12)"
Worksheets("Simethicone Calculation").Range("H12:H21").Formula = "=(G12/57)*100"
Worksheets("Simethicone Calculation").Range("E2").Formula = "LBM-040-05 Release"
ElseIf Range("F1") = 2 Then
Worksheets("Simethicone Calculation").Range("G12:G21").Formula = "=(((E12*$B$6*50)/($B$7*50*C12))*D12)"
Worksheets("Simethicone Calculation").Range("H12:H21").Formula = "=(G12/57)*100"
Worksheets("Simethicone Calculation").Range("E2").Formula = "LBM-040-05 Stability"
ElseIf Range("F1") = 3 Then
Worksheets("Simethicone Calculation").Range("G12:G21").Formula = "=(((E12*$B$6*60)/($B$7*40*C12))*D12)"
Worksheets("Simethicone Calculation").Range("H12:H21").Formula = "=(G12/57)*100"
Worksheets("Simethicone Calculation").Range("E2").Formula = "LBM-046-04"
End Function
I am a novice programmer, so if you could be as simple and specific as possible i would greatly appreciate it.
Thank You in Advance,
Andy