Hello Everyone, I have a form that I am trying to create to insert a new table row and populate some of the row values. My VBA is not great and what I have was built from several different sources. It is working, just not quite like I expect to and I dont understand where the error is coming from.
My Code is as follows.
Private Sub ADD_Click()
'Copy Input Values to Table
Dim oNewRow As ListRow
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("Sheet1").Range("PlateTable")
rng.Select
Set oNewRow = Selection.ListObject.ListRows.ADD(AlwaysInsert:=True)
With ws
oNewRow.Range.Cells(1, 2).Value = Me.THICKtxt
oNewRow.Range.Cells(1, 3).Value = Me.LENGTH
oNewRow.Range.Cells(1, 4).Value = Me.WIDTH
oNewRow.Range.Cells(1, 15).Value = Me.QTY
oNewRow.Range.Cells(1, 16).Value = Me.VENDOR
End With
'Clear Input Controls
Me.THICKtxt = ""
Me.LENGTH = ""
Me.WIDTH = ""
Me.QTY = ""
Me.VENDOR = ""
End Sub
The table updates with all of the data entered except for the WIDTH column. This field dose update but always with the value of 440.25 and then I get a run-time error "13", Type Mismatch. After I debug, it highlights Me.WIDTH = "", and scrolling over I get the message that Me.WIDTH = 440.25
There is no default value set for the txt.box, when the form opens it has a "" value shown, it dose not matter what is entered, it spits out 440.25 and I get the error.
My Code is as follows.
Private Sub ADD_Click()
'Copy Input Values to Table
Dim oNewRow As ListRow
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("Sheet1").Range("PlateTable")
rng.Select
Set oNewRow = Selection.ListObject.ListRows.ADD(AlwaysInsert:=True)
With ws
oNewRow.Range.Cells(1, 2).Value = Me.THICKtxt
oNewRow.Range.Cells(1, 3).Value = Me.LENGTH
oNewRow.Range.Cells(1, 4).Value = Me.WIDTH
oNewRow.Range.Cells(1, 15).Value = Me.QTY
oNewRow.Range.Cells(1, 16).Value = Me.VENDOR
End With
'Clear Input Controls
Me.THICKtxt = ""
Me.LENGTH = ""
Me.WIDTH = ""
Me.QTY = ""
Me.VENDOR = ""
End Sub
The table updates with all of the data entered except for the WIDTH column. This field dose update but always with the value of 440.25 and then I get a run-time error "13", Type Mismatch. After I debug, it highlights Me.WIDTH = "", and scrolling over I get the message that Me.WIDTH = 440.25
There is no default value set for the txt.box, when the form opens it has a "" value shown, it dose not matter what is entered, it spits out 440.25 and I get the error.