• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help with time calculations and formulas

s7yzrs

New Member
Hello everybody,
I have a worksheet where some data is inserted via a userform. Textbox1, textbox2, textbox4 and textbox5 all have a time (format HH:MM). what I would like to achieve is this: when I click on the commandbutton of the userform the data is inserted in the chosen cells. At this point I would like VBA (and not formulas in the worksheet) to calculate the time according to some criteria. For example:

when pressing the commandbutton:

.Cells(2, 14) = TextBox1.Value (this is what I have now)

.cells (2,13)=(2,14)-0.25/24) .value (this is what I would like to get when I insert the value of textbox1 in cell 2,14)
.cells (2,15)=(2,14)+0.37/24) .value

and so on....

is this achievable via VBA?
 
Code:
  .Cells(2, 14) = TextBox1.Value
  .Cells(2, 13).Value = .Cells(2, 14).Value - 0.25 / 24
  .Cells(2, 15).Value = .Cells(2, 14).Value + 0.37 / 24
 
Back
Top