Rabu, 02 Mei 2012

Re: [ExcelVBA] Macro Timer

 

Your problem isn't TElapsed being a String. That's what Format() returns.

Your problem looks to be that you have declared StartTime and StopTime as
String. They need to be numeric.

Try declaring them as Variant and then check in the debugger to see what
they are set to after the time is put in them from "now".

Regards, Dave S

----- Original Message -----
From: "sspatriots" <sspatriots@yahoo.com>
To: <ExcelVBA@yahoogroups.com>
Sent: Thursday, May 03, 2012 1:46 AM
Subject: [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
>
>
>
> ------------------------------------
>
> ----------------------------------
> 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
>
> ----------------------------------Yahoo! Groups Links
>
>
>
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1424 / Virus Database: 2411/4973 - Release Date: 05/02/12
>

__._,_.___
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