Adin
08-15-2012, 01:12 PM
I created a user interface to enter data into a backend excel spreadsheet. One important feature is that this inputs must be entered a numbers and not as texts for I can use pivot tables. While I have been able to have this happened I ran into another problem. I want blank inputs to be entered as a blank, whereas my code currently enters them as "0". Here is a sample of my code below:
Private Sub btnSave_Click()
txtUser = txtUser.Text
txtDateEntered = txtDateEntered.Text
txtProjectedCapex = Val(txtProjectedCapex.Text)
txtCompanyPV = Val(txtCompanyPV.Text)
txtActualCapex = Val(txtActualCapex.Text)
For i = 1 To 5000
If Sheet1.Cells(i, 1).Text = "" Then
opencell = i
Sheet1.Cells(opencell, 1).Value = txtUser.Value
Sheet1.Cells(opencell, 2).Value = txtDateEntered
Sheet1.Cells(opencell, 24).Value = txtProjectedCapex.Value
Sheet1.Cells(opencell, 25).Value = txtCompanyPV.Value
Sheet1.Cells(opencell, 26).Value = txtActualCapex.Value
txtUser.Text = ""
txtDateEntered = ""
txtProjectedCapex.Text = ""
txtCompanyPV.Text = ""
txtActualCapex.Text = "
Exit For
End If
Next i
End Sub
Private Sub btnSave_Click()
txtUser = txtUser.Text
txtDateEntered = txtDateEntered.Text
txtProjectedCapex = Val(txtProjectedCapex.Text)
txtCompanyPV = Val(txtCompanyPV.Text)
txtActualCapex = Val(txtActualCapex.Text)
For i = 1 To 5000
If Sheet1.Cells(i, 1).Text = "" Then
opencell = i
Sheet1.Cells(opencell, 1).Value = txtUser.Value
Sheet1.Cells(opencell, 2).Value = txtDateEntered
Sheet1.Cells(opencell, 24).Value = txtProjectedCapex.Value
Sheet1.Cells(opencell, 25).Value = txtCompanyPV.Value
Sheet1.Cells(opencell, 26).Value = txtActualCapex.Value
txtUser.Text = ""
txtDateEntered = ""
txtProjectedCapex.Text = ""
txtCompanyPV.Text = ""
txtActualCapex.Text = "
Exit For
End If
Next i
End Sub