VBA calculation time

Akbarov

Active Member
Joined
Jun 30, 2018
Messages
347
Office Version
  1. 365
Platform
  1. Windows
Hey community,

I have following code / i wanna know how many seconds it takes this macro to run.

Code:
Sub Brn()
    Dim Markets As Worksheet
    Set Markets = Sheets("sheet4")
    Sheets("DATA").Range("A:A").Name = "run"
    Sheets("DATA").Range("L:L").Name = "aris"
    Sheets("DATA").Range("M:M").Name = "inted"
    Sheets("DATA").Range("E:E").Name = "steri"
    Sheets("sheet4").Range("AP:AP").Name = "byi"
    Markets.Range("e1:e10").Name = "MRET"
    With Sheets("DATA").Cells(5, "w")
    .FormulaArray = "=sum(if((isnumber(match(run,mret,0)))*(aris>0)*(run<>"""")*(not(isnumber(match(steri,byi,0)))),printed))"
    .Value = .Value
End With
End Sub

How can add following code to my VBA?
Code:
[COLOR=#00007F][FONT=&quot]Sub[/FONT][/COLOR][COLOR=#403F41][FONT=&quot] CalculateRunTime_Seconds()[/FONT][/COLOR]


[COLOR=#00007F][FONT=&quot]Dim[/FONT][/COLOR][COLOR=#403F41][FONT=&quot] StartTime [/FONT][/COLOR][COLOR=#00007F][FONT=&quot]As[/FONT][/COLOR][COLOR=#403F41][FONT=&quot] [/FONT][/COLOR][COLOR=#00007F][FONT=&quot]Double[/FONT][/COLOR]
[COLOR=#00007F][FONT=&quot]Dim[/FONT][/COLOR][COLOR=#403F41][FONT=&quot] SecondsElapsed [/FONT][/COLOR][COLOR=#00007F][FONT=&quot]As[/FONT][/COLOR][COLOR=#403F41][FONT=&quot] [/FONT][/COLOR][COLOR=#00007F][FONT=&quot]Double[/FONT][/COLOR]


[COLOR=#403F41][FONT=&quot]  StartTime = Timer[/FONT][/COLOR]

[COLOR=#007F00][FONT=&quot]'*****************************[/FONT][/COLOR]
[COLOR=#007F00][FONT=&quot]'Insert Your Code Here...[/FONT][/COLOR]
[COLOR=#007F00][FONT=&quot]'*****************************[/FONT][/COLOR]

[COLOR=#403F41][FONT=&quot]  SecondsElapsed = Round(Timer - StartTime, 2)[/FONT][/COLOR]


[COLOR=#403F41][FONT=&quot]  MsgBox "This code ran successfully in " & SecondsElapsed & " seconds", vbInformation[/FONT][/COLOR]

[COLOR=#00007F][FONT=&quot]End[/FONT][/COLOR][COLOR=#403F41][FONT=&quot] [/FONT][/COLOR][COLOR=#00007F][FONT=&quot]Sub[/FONT][/COLOR]

I am getting sub error
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Code:
Sub CalculateRunTime_Seconds()


Dim StartTime [COLOR="#0000CD"][B]AsDouble[/B][/COLOR]
Dim SecondsElapsed [COLOR="#0000CD"][B]AsDouble[/B][/COLOR]


  StartTime = Timer

'*****************************
'Insert Your Code Here...
'*****************************

  SecondsElapsed = Round(Timer - StartTime, 2)


  MsgBox "This code ran successfully in " & SecondsElapsed & " seconds", vbInformation

[COLOR="#0000CD"][B]EndSub[/B][/COLOR]
There may be other issues but at least those blue items should all be 2 words.

If that is not the only problem then please be more specific about the exact error message, and post your whole combined code.
 
Upvote 0
Thanks for reply,

can you please tell me how can i make this formula with 2 match criteria?

Code:
[COLOR=#333333]match(run,mret,0)[/COLOR]
and
Code:
[COLOR=#333333]match(aris,inted,0)[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,684
Members
448,977
Latest member
dbonilla0331

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