Moonbeam111
Board Regular
- Joined
- Sep 24, 2018
- Messages
- 97
- Office Version
- 365
- 2010
I ranges E41:E49 i have times:
I have a function here that I call on:
But it doesnt work if I call it while I have the "minutes" text in the range of cells. It just automatically does this:
Id like to keep the text and number in the same cell. Does anyone have the knowledge necessary to know how to fix this? If its possible at all?
0:20 minutes |
0:48 minutes |
0:13 minutes |
0:33 minutes |
0:22 minutes |
0:10 minutes |
0:00 minutes |
0:00 minutes |
1:29 minutes |
I have a function here that I call on:
VBA Code:
Function CalcHrsMins(TotalMinutes As Variant) As Variant
Dim varHours, varMinutes
'calculate the hours
varHours = Int(TotalMinutes / 60)
'calculate the remaining minutes
varMinutes = Format(TotalMinutes - (varHours * 60), "00")
'return the combined hours and minutes
CalcHrsMins = varHours & ":" & varMinutes
End Function
VBA Code:
Sub test()
Dim varTotHours As Variant
Dim varHrsMinutes As Variant
Dim time As Range
For Each time In Range("E41:E49")
varTotHours = time
varHrsMinutes = CalcHrsMins(varTotHours)
time = varHrsMinutes
Next time
End Sub
But it doesnt work if I call it while I have the "minutes" text in the range of cells. It just automatically does this:
minutes |
minutes |
minutes |
minutes |
minutes |
minutes |
minutes |
minutes |
minutes |
Id like to keep the text and number in the same cell. Does anyone have the knowledge necessary to know how to fix this? If its possible at all?