Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add minutes to a time (hh:mm) in excel vba

Tags:

excel

vba

I am making a production schedule, and would like to add ex. 78 minutes to a time ex. 7:05 (am) in VBA. How would I go about doing this? This is what I have tried so far, but I'm getting an error 13 type:mismatch

Dim TUntilPump As Integer
Dim TFPump As Long, TStartPump As Long

TUP = 78
TFP = Time(0, TUP, 0)
TSP = Time(7,05,0) + TFP

I'm thinking it has something to do with my variable dimensions or the format of my times, but I have no idea what I'm doing wrong. Any help is appreciated, and thanks in advance!

like image 879
FruitUser Avatar asked Jan 07 '16 20:01

FruitUser


People also ask

How do I add 1 minute to a time in Excel?

1. If you want to add one minute to cell, use this formula:=A2+1/1440, if you want to add one second to cell, use this formula: =A2+1/86400. 2. In above formulas, 1 indicates to add one hour or one minute or one second, you can change it as you need.

How do I add a time delay to a macro in Excel?

Use the VBA Application. Wait method to pause your macro for a specific amount of time. Application. Wait is a simple way to delay your macro by a fixed number of seconds.


1 Answers

use the DATEADD function:

TRP = dateadd("n",78,"7:05:00")

the "n" means minutes.

like image 169
Scott Craner Avatar answered Sep 28 '22 10:09

Scott Craner