Rabu, 02 Mei 2012

[ExcelVBA] Macro Timer

 

Hi,

I have a macro that is executed with a command button click. In that macro I'm trying to put a stop watch on how long it takes to execute that code. Below is what I have, however, I keep getting a 'Type Mis-match' error when I run it when it gets to 'TElapsed'. I'm not sure what to do to correct the mis-match. I'm guessing it has something to do with the 'Dim TElapsed As String'. Any ideas greatly appreciated.

Thanks,

Steve

Private Sub CommandButton1_Click()

Dim StartTime As String
Dim StopTime As String
Dim TElapsed As String

StartTime = Now

Call TimedMsgbox1

Call TimedMsgbox2

ssGetPRMData.GetPRMData



Call TimedMsgbox3

ssGetFltrCntQALogData.GetNewQALogData_4TtlFltrCntInsp



Application.Calculation = xlAutomatic


StopTime = Now
TElapsed = Format(StopTime - StartTime, "hh:mm:ss")
MsgBox TElapsed


End Sub

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar