Hey guys! Thanks so much for answering ALL my questions all the time. I am working on a macro here to do something specific. Say you are working with a process over long periods of time and you want to know how many minutes there are when the process is turned on and off. The macro will first ask the user to input hours on, hours off, minutes on, then minutes off. Data might look like this: 7 hours (on) 33 minutes (on) and 9 hours (off) 22 minutes (off). The macro should then calculate the difference between 9 hrs 22 mins and 7 hrs 33 mins. So far I have this:
Option Explicit
Sub problem2()
Dim totalmin As Double
Dim Deltamin As Double
Dim HON As Double
Dim MON As Double
Dim HOFF As Double
Dim MOFF As Double
Dim answer As String
HON = InputBox("Input hours on")
HOFF = InputBox("Input hours off")
MON = InputBox("Input minutes on")
MOFF = InputBox("Input minutes off")
totalmin = 0
Deltamin = 0
Do While answer = "yes"
Deltamin = (HOFF - HON) * 60 + (MOFF - MON)
totalmin = totalmin + Deltamin
Loop
answer = InputBox("More data? yes or no")
If answer = "no" Then
MsgBox "Total is " & totalmin
Wend
answer
End Sub
Can someone help me fix this? I know it needs to be a Do While there is more data to input loop. Answer should pop up in a message box. Thank you.
Option Explicit
Sub problem2()
Dim totalmin As Double
Dim Deltamin As Double
Dim HON As Double
Dim MON As Double
Dim HOFF As Double
Dim MOFF As Double
Dim answer As String
HON = InputBox("Input hours on")
HOFF = InputBox("Input hours off")
MON = InputBox("Input minutes on")
MOFF = InputBox("Input minutes off")
totalmin = 0
Deltamin = 0
Do While answer = "yes"
Deltamin = (HOFF - HON) * 60 + (MOFF - MON)
totalmin = totalmin + Deltamin
Loop
answer = InputBox("More data? yes or no")
If answer = "no" Then
MsgBox "Total is " & totalmin
Wend
answer
End Sub
Can someone help me fix this? I know it needs to be a Do While there is more data to input loop. Answer should pop up in a message box. Thank you.