i have a excel file where is do a daily log of my items i want to put 5 value in one colum but i dont know how to
it works with one value but the other 4 are not registering this is my code it only registers the last one
Private Sub cmdsave_Click()
Dim myRow As ListRow
Dim introws As Integer
Dim item1 As String
Dim item2 As String
Dim item3 As String
Dim item4 As String
Dim item5 As String
Dim itempack1 As String
Dim itempack2 As String
Dim itempack3 As String
Dim itempack4 As String
Dim itempack5 As String
If Me.tbp1_1.Value >= 0 Then
item1 = ActiveWorkbook.Worksheets("db").Range("b2").Value
End If
If Me.tbp1_2.Value >= 0 Then
item2 = ActiveWorkbook.Worksheets("db").Range("b3").Value
End If
If Me.tbp1_3.Value >= 0 Then
item3 = ActiveWorkbook.Worksheets("db").Range("b4").Value
End If
If Me.tbp1_4.Value >= 0 Then
item4 = ActiveWorkbook.Worksheets("db").Range("b5").Value.ListRows.Add(4)
End If
If Me.tbp1_5.Value >= 0 Then
item5 = ActiveWorkbook.Worksheets("db").Range("b6").Value
End If
introw = ActiveWorkbook.Worksheets("rawdata").ListObjects("tbldata").ListRows.Count
Set myRow = ActiveWorkbook.Worksheets("rawdata").ListObjects("tbldata").ListRows.Add(introw)
myRow.Range(1) = Me.tb1.Value
myRow.Range(2) = item1
myRow.Range(2) = item2
myRow.Range(2) = item3
myRow.Range(2) = item4
myRow.Range(2) = item5
If Me.tbp1_1.Value >= 0 Then
itempack1 = ActiveWorkbook.Worksheets("db").Range("c2").Value
End If
If Me.tbp1_2.Value >= 0 Then
itempack2 = ActiveWorkbook.Worksheets("db").Range("c3").Value
End If
If Me.tbp1_3.Value >= 0 Then
itempack3 = ActiveWorkbook.Worksheets("db").Range("c4").Value
End If
If Me.tbp1_4.Value >= 0 Then
itempack4 = ActiveWorkbook.Worksheets("db").Range("c5").Value
End If
If Me.tbp1_5.Value >= 0 Then
itempack5 = ActiveWorkbook.Worksheets("db").Range("c6").Value
End If
myRow.Range(3) = itempack1
myRow.Range(3) = itempack2
myRow.Range(3) = itempack3
myRow.Range(3) = itempack4
myRow.Range(3) = itempack5
Me.tb1.Value = ""
Me.tbp1_1.Value = ""
Me.tbp1_2.Value = ""
Me.tbp1_3.Value = ""
Me.tbp1_4.Value = ""
Me.tbp1_5.Value = ""
it works with one value but the other 4 are not registering this is my code it only registers the last one
Private Sub cmdsave_Click()
Dim myRow As ListRow
Dim introws As Integer
Dim item1 As String
Dim item2 As String
Dim item3 As String
Dim item4 As String
Dim item5 As String
Dim itempack1 As String
Dim itempack2 As String
Dim itempack3 As String
Dim itempack4 As String
Dim itempack5 As String
If Me.tbp1_1.Value >= 0 Then
item1 = ActiveWorkbook.Worksheets("db").Range("b2").Value
End If
If Me.tbp1_2.Value >= 0 Then
item2 = ActiveWorkbook.Worksheets("db").Range("b3").Value
End If
If Me.tbp1_3.Value >= 0 Then
item3 = ActiveWorkbook.Worksheets("db").Range("b4").Value
End If
If Me.tbp1_4.Value >= 0 Then
item4 = ActiveWorkbook.Worksheets("db").Range("b5").Value.ListRows.Add(4)
End If
If Me.tbp1_5.Value >= 0 Then
item5 = ActiveWorkbook.Worksheets("db").Range("b6").Value
End If
introw = ActiveWorkbook.Worksheets("rawdata").ListObjects("tbldata").ListRows.Count
Set myRow = ActiveWorkbook.Worksheets("rawdata").ListObjects("tbldata").ListRows.Add(introw)
myRow.Range(1) = Me.tb1.Value
myRow.Range(2) = item1
myRow.Range(2) = item2
myRow.Range(2) = item3
myRow.Range(2) = item4
myRow.Range(2) = item5
If Me.tbp1_1.Value >= 0 Then
itempack1 = ActiveWorkbook.Worksheets("db").Range("c2").Value
End If
If Me.tbp1_2.Value >= 0 Then
itempack2 = ActiveWorkbook.Worksheets("db").Range("c3").Value
End If
If Me.tbp1_3.Value >= 0 Then
itempack3 = ActiveWorkbook.Worksheets("db").Range("c4").Value
End If
If Me.tbp1_4.Value >= 0 Then
itempack4 = ActiveWorkbook.Worksheets("db").Range("c5").Value
End If
If Me.tbp1_5.Value >= 0 Then
itempack5 = ActiveWorkbook.Worksheets("db").Range("c6").Value
End If
myRow.Range(3) = itempack1
myRow.Range(3) = itempack2
myRow.Range(3) = itempack3
myRow.Range(3) = itempack4
myRow.Range(3) = itempack5
Me.tb1.Value = ""
Me.tbp1_1.Value = ""
Me.tbp1_2.Value = ""
Me.tbp1_3.Value = ""
Me.tbp1_4.Value = ""
Me.tbp1_5.Value = ""