VBA Help, Form to update table acting strange

TDC21

Board Regular
Joined
Mar 31, 2017
Messages
97
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.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
try naming the text box something else
Width is a reserved word... and a property of the form itself (ie: the Me)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top