Hi
I use a Microsoft Excel 2013, I'm trying to dynamically set a formula into a cell using VBA code.
(i) I declared Const (Formula1).
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Application.DisplayStatusBar = False
Dim Product As String
Const Formula1 = "=INDEX(Dailydose!$A$2:$C$58;MATCH(1,($E$3=Dailydose!$A$2:$A$58)*($D$5=Dail ydose!$B$2:$B$58),0),3)"
....
(ii) I applied Sheet.Range.FormulaLocal command, but I got an error message: Run-time error '1004' - Application defined or object-defined error
If Target.Address = "$E$4" Then
....
Select Case Range("E4")
Case "Parenteral Only":
DoUnLockCell ("E5")
DoSetYellowColorCell ("E5")
Sheet1.Range("E5").FormulaLocal = Formula1
DoLockCell ("E5")
.....
(iii)
I tried with "Sheet.Range.FormulaArray", but I run into the same error message.
If I use Formula1 (=index(...)...) on the worksheet directly, I need to use special characters around the formula. { and }
I would appreciate if somebody could help me.
Regards
zk69