Input value to last row +1 & +2

jamesa123

New Member
Joined
Nov 24, 2022
Messages
2
Office Version
  1. 365
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 = ""

1669303027878.png
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,215,012
Messages
6,122,682
Members
449,091
Latest member
peppernaut

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