Pretty new to Excel. Putting together a user form with 8 different text boxes. In those text boxes should be numbers the user puts in. I have a code that automatically add the numbers from the text boxes and input them into a cell on the worksheet (half into one, half into the other one). Problem is, I also have a checkbox option for no data to enter. When this is checked, I would like the 8 text boxes (4 at a time, 2 check boxes) to read "#N/A," which I have accomplished. I also want the sum of those 4 "#N/A"s to equal "#N/A" once the "okay" command button click event happens (to keep the integrity of a chart I have linked to the worksheet).
Here is a piece of the VBA I have put together
adds the 4 cells together and places on the sheet
ActiveCell.Offset(5, 0) = CDbl(txtINDIVIDUALLY.Value) + CDbl(txtINTERPERSONALLY.Value) + CDbl(txtSOCIALLY.Value) + CDbl(txtOVERALL.Value)
This isn't right obviously, but it's my best attempt so far.
If CDbl(txtRELATIONSHIP.Value) + CDbl(txtGOALS.Value) + CDbl(txtAPPROACH.Value) + CDbl(txtOVERALLSRS.Value) = "#N/A" Then
ActiveCell.Offset(5, 0) = "N/A"
Here's more of the code that may be pertinent -
Private Sub chkbxNOORS_Change()
If Me.chkbxNOORS.Value = True Then
Me.txtINDIVIDUALLY.Value = "#N/A"
Me.txtINTERPERSONALLY.Value = "#N/A"
Me.txtSOCIALLY.Value = "#N/A"
Me.txtOVERALL.Value = "#N/A"
Else
Me.txtINDIVIDUALLY.Value = ""
Me.txtINTERPERSONALLY.Value = ""
Me.txtSOCIALLY.Value = ""
Me.txtOVERALL.Value = ""
End If
End Sub
Private Sub chkbxNOSRS_Change()
If Me.chkbxNOSRS.Value = True Then
Me.txtRELATIONSHIP.Value = "#N/A"
Me.txtGOALS.Value = "#N/A"
Me.txtAPPROACH.Value = "#N/A"
Me.txtOVERALLSRS.Value = "#N/A"
Else
Me.txtRELATIONSHIP.Value = ""
Me.txtGOALS.Value = ""
Me.txtAPPROACH.Value = ""
Me.txtOVERALLSRS.Value = ""
End If
End Sub
Private Sub cmdOKAY_Click()
Dim RowCount As Long
Dim ctl As Control
ActiveWorkbook.ActiveSheet.Activate
Range("C10").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(0, 1).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtDATE.Value
ActiveCell.Offset(1, 0) = txtINDIVIDUALLY.Value
ActiveCell.Offset(2, 0) = txtINTERPERSONALLY.Value
ActiveCell.Offset(3, 0) = txtSOCIALLY.Value
ActiveCell.Offset(4, 0) = txtOVERALL.Value
ActiveCell.Offset(5, 0) = CDbl(txtINDIVIDUALLY.Value) + CDbl(txtINTERPERSONALLY.Value) + CDbl(txtSOCIALLY.Value) + CDbl(txtOVERALL.Value)
Range("C10").Select
If CDbl(txtRELATIONSHIP.Value) + CDbl(txtGOALS.Value) + CDbl(txtAPPROACH.Value) + CDbl(txtOVERALLSRS.Value) = "#N/A" Then
ActiveCell.Offset(5, 0) = "N/A"
End If
ActiveWorkbook.ActiveSheet.Activate
Range("C17").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(0, 1).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtDATE.Value
ActiveCell.Offset(1, 0) = txtRELATIONSHIP.Value
ActiveCell.Offset(2, 0) = txtGOALS.Value
ActiveCell.Offset(3, 0) = txtAPPROACH.Value
ActiveCell.Offset(4, 0) = txtOVERALLSRS.Value
ActiveCell.Offset(5, 0) = CDbl(txtRELATIONSHIP.Value) + CDbl(txtGOALS.Value) + CDbl(txtAPPROACH.Value) + CDbl(txtOVERALLSRS.Value)
Range("C17").Select
If CDbl(txtRELATIONSHIP.Value) + CDbl(txtGOALS.Value) + CDbl(txtAPPROACH.Value) + CDbl(txtOVERALLSRS.Value) = "#N/A" Then
ActiveCell.Offset(5, 0) = "N/A"
End If
End Sub
Bookmarks