Hi,
I have a program that runs as soon as you open it it asks to enter the details, then it loads it onto the spreadsheet moving the other cells down 1. What I need now and it is doing my head in haha. When I enter the new details which will always be greater than the last ones I have entered I need it to automatically subtract it from it.
What I am doing is entering the power usage, so when it appears on the spreadsheet it shows the amount used since the last recording not the total amount.
I have tried all sorts of things but I know it's a simple fix but its just one of them things.
Private Sub CommandButton1_Click()
If Range("a2") <> "" Then
Rows("2:2").Select
Selection.Insert shift:=xlDown
End If
If Range("a2") = "" Then
Range("a2") = TextBox1.Text
Range("B2") = TextBox2.Text
Range("C2") = TextBox3.Text
Range("D2") = TextBox4.Text
End If
TextBox1.Text = Format(Now(), "dd-mmm-yy")
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Range("c1").Select
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub Label2_Click()
End Sub
Private Sub Label3_Click()
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub UserForm_Initialize()
TextBox1.Text = Format(Now(), "dd-mmm-yy")
End Sub
I have a program that runs as soon as you open it it asks to enter the details, then it loads it onto the spreadsheet moving the other cells down 1. What I need now and it is doing my head in haha. When I enter the new details which will always be greater than the last ones I have entered I need it to automatically subtract it from it.
What I am doing is entering the power usage, so when it appears on the spreadsheet it shows the amount used since the last recording not the total amount.
I have tried all sorts of things but I know it's a simple fix but its just one of them things.
Private Sub CommandButton1_Click()
If Range("a2") <> "" Then
Rows("2:2").Select
Selection.Insert shift:=xlDown
End If
If Range("a2") = "" Then
Range("a2") = TextBox1.Text
Range("B2") = TextBox2.Text
Range("C2") = TextBox3.Text
Range("D2") = TextBox4.Text
End If
TextBox1.Text = Format(Now(), "dd-mmm-yy")
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Range("c1").Select
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub Label2_Click()
End Sub
Private Sub Label3_Click()
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub UserForm_Initialize()
TextBox1.Text = Format(Now(), "dd-mmm-yy")
End Sub