Hi All,
Need some help, I have 2 user forms that I am using to add data to a list. 1 of the VBA codes works fine, so I copied it and changed the cells and assigned it to another user form command button (commandbutton11) however, this one that i copied is not working and stops working at line "LastrowBZ = Sheets(SN).Cells(Rows.Count, "BZ").End(xlUp).Row + 1" Can someone help me fix this ....
Here's the code that DOES NOT work:
Here's the original code that works, that I copied and pasted
Need some help, I have 2 user forms that I am using to add data to a list. 1 of the VBA codes works fine, so I copied it and changed the cells and assigned it to another user form command button (commandbutton11) however, this one that i copied is not working and stops working at line "LastrowBZ = Sheets(SN).Cells(Rows.Count, "BZ").End(xlUp).Row + 1" Can someone help me fix this ....
Here's the code that DOES NOT work:
Code:
Private Sub CommandButton11_Click()'Modified 6/22/2019 2:19:53 AM EDT
Dim SN As String
SN = Range("E4").Value
Dim LastrowBZ As Long
LastrowBZ = Sheets(SN).Cells(Rows.Count, "BZ").End(xlUp).Row + 1
If LastrowBZ < 138 Then LastrowBZ = 138
Dim LastrowCB As Long
LastrowCB = Sheets(SN).Cells(Rows.Count, "CB").End(xlUp).Row + 1
If LastrowCB < 138 Then LastrowCB = 138
Sheets(SN).Cells(LastrowAZ, "BZ").Value = TextBox1.Value
Sheets(SN).Cells(LastrowBB, "CB").Value = TextBox2.Value
With Sheets(SN)
.Range("CA138").Value = ActiveSheet.Range("E4").Value & .Range("BZ138").Value
End With
End Sub
Here's the original code that works, that I copied and pasted
Code:
Private Sub CommandButton1_Click()'Modified 6/22/2019 2:19:53 AM EDT
Dim SN As String
SN = Range("E4").Value
Dim LastrowAZ As Long
LastrowAZ = Sheets(SN).Cells(Rows.Count, "AZ").End(xlUp).Row + 1
If LastrowAZ < 160 Then LastrowAZ = 160
Dim LastrowBB As Long
LastrowBB = Sheets(SN).Cells(Rows.Count, "BB").End(xlUp).Row + 1
If LastrowBB < 160 Then LastrowBB = 160
Sheets(SN).Cells(LastrowAZ, "AZ").Value = TextBox1.Value
Sheets(SN).Cells(LastrowBB, "BB").Value = TextBox2.Value
With Sheets(SN)
.Range("BA160").Value = ActiveSheet.Range("E4").Value & .Range("AZ160").Value
End With
End Sub