Hello All,
I have this script for moving data from a userform to a TABLE on a sheet called Main. This is not working as the line "LR = Main.Cells(Rows.Count, "A").End(x1up).Row" keeps stopping.
Can you have a look and let me know if you can see anything wrong.
SideNote: I would also like a code to create a formula "=VLOOKUP(B2,Config!$A$2:$B$5,2,0)" to go into column F
I have this script for moving data from a userform to a TABLE on a sheet called Main. This is not working as the line "LR = Main.Cells(Rows.Count, "A").End(x1up).Row" keeps stopping.
Can you have a look and let me know if you can see anything wrong.
SideNote: I would also like a code to create a formula "=VLOOKUP(B2,Config!$A$2:$B$5,2,0)" to go into column F
Code:
Private Sub CommandButton1_Click()
Dim LR As Integer, Main As Worksheet
Set Main = ThisWorkbook.Worksheets("Main")
LR = Main.Cells(Rows.Count, "A").End(x1up).Row
If LR = 2 And Cells(LR, "A").Value = "" Then
LR = LR
Else
LR = LR + 1
End If
Main.Cells(LR, "A").Value = TextBox1.Value
Main.Cells(LR, "B").Value = ComboBox1.Value
Main.Cells(LR, "C").Value = TextBox2.Value
Main.Cells(LR, "D").Value = ComboBox2.Value
Main.Cells(LR, "E").Value = CheckBox1.Value
Main.Cells(LR, "G").Value = TextBox3.Value
TextBox1.Value = ""
ComboBox1.Value = ""
TextBox2.Value = ""
ComboBox2.Value = ""
CheckBox1.Value = ""
TextBox3.Value = ""
New_Account.Hide
End Sub