|
-
Aug 15th, 2007, 10:14 AM
#1
Thread Starter
New Member
[EXCEL]summing times
I have a spreadsheet that has a column of times in the format hh:mm. They are not times like 12:00 AM, it would be more like 12 hours and 0 minutes. I want to add up all the times in visual basic, and have a variable that I can use, that has the total number of minutes in the column. Can anyone help?
-
Aug 15th, 2007, 04:49 PM
#2
Re: [EXCEL]summing times
It would be easier if you had it entered in a decimal format so it would be like 12.0 for 12 hours and no minutes or 3.75 for threee hours and 45 minutes. etc. Then it would be a simple SUM forumla.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 16th, 2007, 06:10 AM
#3
Re: [EXCEL]summing times
if the cells are formated time then you can just sum the times
problem though, at 24 hrs starts again
if you have the total time in minutes you can easily calculate the time in hours from that
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 16th, 2007, 07:58 AM
#4
Re: [EXCEL]summing times
With Excel, you can do much easier than Access or other apps:
Format the cells with [h]:mm
then you can add or subtruct them as normal numbers.
Ex.: 16:38 + 9:23 = 26:01
If format the cells as h:mm, it will display 02:01 instead of 26:01
-
Aug 16th, 2007, 09:01 AM
#5
Thread Starter
New Member
Re: [EXCEL]summing times
I ended up assigning the value of the cell to a variable that was declared as a date, using 'DatePart' to extract the hour and minute, and calculating the total minutes from that. Thanks though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|