Hi Guys
How can I make this code work. I'm just not getting anything right today...
Dim wks As Worksheet
Dim tbl As ListObject
Dim RowRef As Long
Dim Item As String
Dim c As Integer
Item = TextBox2.Text
Set wks = Sheet15
Set tbl = wks.ListObjects("Table40")
For c = 2 To 200
If Sheets("Ingredients").Cells(c, 1) Like Item Then
Sheets("Ingredients").Cells(c, 2) = TextBox1
Sheets("Ingredients").Cells(c, 3) = ComboBox1
Sheets("Ingredients").Cells(c, 6) = ComboBox2
Sheets("Ingredients").Cells(c, 9) = ComboBox3
Else GoTo AddIngredient
End If
Next
AddIngredient:
With tbl
.ListRows.Add
RowRef = .ListRows.Count
.DataBodyRange(RowIndex:=RowRef, columnindex:=1).Value = TextBox2
.DataBodyRange(RowIndex:=RowRef, columnindex:=2).Value = TextBox1
.DataBodyRange(RowIndex:=RowRef, columnindex:=3).Value = ComboBox1
.DataBodyRange(RowIndex:=RowRef, columnindex:=6).Value = ComboBox2
.DataBodyRange(RowIndex:=RowRef, columnindex:=9).Value = ComboBox3
End With
Unload Me
End Sub
Bookmarks