Convert format to vba code

sofas

Active Member
Joined
Sep 11, 2022
Messages
478
Office Version
  1. 2019
Platform
  1. Windows
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
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,363
Messages
6,124,505
Members
449,166
Latest member
hokjock

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top