Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Time Calculation

Getting a type mismatch error.

I have a cell (A1) with a custom format of mm:ss
I have a macro that is run that should add :10 seconds to the time, but I am
getting a type mimatch error. Not sure why.
Range("A1").value = Range("A1").value + time(0,0,10)

Please advise.

Thanks,
Doug


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Time Calculation

In VBA it is TimeSerial:
Range("A1").value = Range("A1").value + timeserial(0,0,10)

--
Regards,
Tom Ogilvy



"HeartSA" wrote in message
...
Getting a type mismatch error.

I have a cell (A1) with a custom format of mm:ss
I have a macro that is run that should add :10 seconds to the time, but I

am
getting a type mimatch error. Not sure why.
Range("A1").value = Range("A1").value + time(0,0,10)

Please advise.

Thanks,
Doug




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Time Calculation

Probably because the VBA Time function isn't the same as the Excel Worksheet
function of the same name. Use DateAdd

Range("A1") = DateAdd("s",10, Range("A1"))
or
Range("A1") = Range("A1") + TimeSerial(0, 0, 10)


If that doesn't work then maybe A1 is text rather than numeric:
Range("A1") = DateAdd("s",10, DateValue(Range("A1")))

HTH,

--
George Nicholson

Remove 'Junk' from return address.


"HeartSA" wrote in message
...
Getting a type mismatch error.

I have a cell (A1) with a custom format of mm:ss
I have a macro that is run that should add :10 seconds to the time, but I
am
getting a type mimatch error. Not sure why.
Range("A1").value = Range("A1").value + time(0,0,10)

Please advise.

Thanks,
Doug




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Time Calculation

Thank you both, that did the trick.


"Tom Ogilvy" wrote in message
...
In VBA it is TimeSerial:
Range("A1").value = Range("A1").value + timeserial(0,0,10)

--
Regards,
Tom Ogilvy



"HeartSA" wrote in message
...
Getting a type mismatch error.

I have a cell (A1) with a custom format of mm:ss
I have a macro that is run that should add :10 seconds to the time, but

I
am
getting a type mimatch error. Not sure why.
Range("A1").value = Range("A1").value + time(0,0,10)

Please advise.

Thanks,
Doug






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop time - start time calculation squack21 Excel Worksheet Functions 5 December 10th 07 03:20 PM
Time calculation (Subraction of Idle Time) Ajay Excel Discussion (Misc queries) 6 March 4th 07 11:54 AM
Time calculation Jon Grant Excel Worksheet Functions 2 October 13th 06 12:11 PM
Ignoring Time in a Date Time Calculation nmp Excel Worksheet Functions 3 November 23rd 05 08:32 PM
time calculation with military time Ron Thetford Excel Worksheet Functions 8 July 29th 05 07:24 PM


All times are GMT +1. The time now is 12:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"