Hello, I have a table to fetch data through formulas. I want to convert the formulas into code. I have already done that. The problem I am facing is the code execution time is rather slow. Is there a better suggestion?
VBA Code:
Sub Macro1()
Dim dataWS As Worksheet
Dim ST1 As String, ST2 As String
Set dataWS = Worksheets("sheet1")
Application.ScreenUpdating = False
ST1 = Replace("=IFERROR(INDEX(Data2,MATCH(RC[51],Day,0),MATCH(R6C2,R6C2:R6C7,0)),"""")", _
"dataWS", "'" & dataWS.Name & "'")
' st1= =IFERROR(INDEX(Data2;MATCH(BL7;Day;0);MATCH($B$6;$B$6:$G$6;0));"")
ST2 = Replace("=IFERROR(INDEX(Data2,MATCH(RC[51],Day,0),MATCH(R6C6,R6C2:R6C7,0)),"""")", _
"dataWS", "'" & dataWS.Name & "'")
'st2= =IFERROR(INDEX(Data2;MATCH(BL8;Day;0);MATCH($F$6;$B$6:$G$6;0));"")
With dataWS
For st3 = 7 To 94 Step 2
dataWS.Range(Cells(st3, "m"), dataWS.Cells(st3, "be")).Formula = ST1
Next st3
For st4 = 8 To 93 Step 2
dataWS.Range(Cells(st4, "m"), dataWS.Cells(st4, "be")).Formula = ST2
Next st4
'.Range("m7:be94").Value = .Range("m7:be94").Value
End With
End Sub