Trueblue862
Board Regular
- Joined
- May 24, 2020
- Messages
- 160
- Office Version
- 365
- Platform
- Windows
I have a spreadsheet which I am using to perform simple calculations, dependent on certain variables. I'm using a userform to input data into certain cells in the spreadsheet, the only problem I'm having is I have to enter data into every field every time I want to tweak something in the calculation, which becomes very tedious. What I'm trying to achieve is essentially if the textbox has no data in it, then it is simply ignored and the code moves to the next textbox. Below is my very amateur attempt at this, I have tried a few variations on this and haven't really achieved anything in a number of hours. Any help would be greatly appreciated.
VBA Code:
Sub save_values()
If TextBox1.Value <= 0 Then
If TextBox2.Value > 0 Then Sheets("Ridge Line Metric").Range("A3") = Me.TextBox1.Value
End If
If TextBox2.Value <= 0 Then
If TextBox2.Value > 0 Then Sheets("Ridge Line Metric").Range("H8") = Me.TextBox2.Value
End If
If TextBox3.Value <= 0 Then
If TextBox3.Value > 0 Then Sheets("Ridge Line Metric").Range("N9") = Me.TextBox3.Value
End If
If TextBox4.Value <= 0 Then
If TextBox4.Value > 0 Then Sheets("Ridge Line Metric").Range("T9") = Me.TextBox4.Value
End If
End Sub