VBA calculation time

Akbarov

Board Regular
Joined
Jun 30, 2018
Messages
100
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
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
46,165
Office Version
  1. 365
Platform
  1. Windows
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.
 

Akbarov

Board Regular
Joined
Jun 30, 2018
Messages
100
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]
 

Watch MrExcel Video

Forum statistics

Threads
1,108,655
Messages
5,524,135
Members
409,562
Latest member
meeranaskar

This Week's Hot Topics

Top