Hello here,
I need some help to make my code work. I need vba to make automatically calculations bettween two periodes:
- 1st june and 1st nov
- 1st nov and 1st june
Thanks in advance for your advises.
De code looks like this:
I need some help to make my code work. I need vba to make automatically calculations bettween two periodes:
- 1st june and 1st nov
- 1st nov and 1st june
Thanks in advance for your advises.
De code looks like this:
Code:
Private Sub CommandButton1_Click()
Dim d As Date, t As Date, startTime1 As Date, startTime2 As Date, startTime3 As Date, Op As String, Vgem As String
d = CDate(TextBox1.Text)
d = TextBox1.Value
TextBox1.Value = Format(TextBox1.Value, "DD-MM-YYYY")
t = CDate(TextBox2.Text)
t = TextBox2.Value
TextBox2.Value = Format(TextBox2.Value, "hh:mm")
startTime1 = #1/6/2014#
startTime2 = #1/11/2014#
startTime3 = CDate("06:00")
startTime3 = CDate("20:00")
Range("b2").Value = d
Range("a2").Value = "Date"
Range("c1").Value = "Opbrengst"
Range("d1").Value = "Gemiddel dagverbruik"
If d > startTime1 And startTime2 > d Then Op = (2690 * (1 / 180))
TextBox3.Value = Op
TextBox3.Value = Format(TextBox3.Value, "0.000")
Range("c2").Value = TextBox3.Value
If d > startTime1 And startTime2 > d Then Vgem = 4120 * (1 / 180)
TextBox4.Value = Vgem
TextBox4.Value = Format(TextBox4.Value, "0.000")
Range("d2").Value = TextBox4.Value
End Sub
Comment