1
Dear, I am new in VBA and for my project I am trying to make a userform that feeds a spreadsheet according to the information that the user input. I’m having a mistake I don’t understand how to fix..
Error shows to be in line: Lin = Ws. Cells(Rows.Count, 1). End(x1Up). Offset(1, 0). Row
Follows the script:
Private Sub Enter_Click()
Dim iLin As String
Dim ws As Worksheet
Set ws = Worksheets("ADAE")
lin = ws.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row
If Trim(Me.title) = "" Then
MsgBox "Informe o Título da Planilha"
Me.title.SetFocus
Exit Sub
End If
If Not (IsNumeric(Me.nidaula)) Then
MsgBox "Digite um número válido"
Me.nidaula.SetFocus
Exit Sub
End If
If Not (Me.TM) And Not (Me.TC) Then
MsgBox "Selecione o tipo de tarefa"
Exit Sub
End If
If Not (IsNumeric(Me.group)) Then
MsgBox "Digite um número válido"
Me.nidaula.SetFocus
Exit Sub
End If
ws.Cells(lin, 1).Value = Me.title.Value
ws.Cells(lin, 2).Value = Me.nidaula.Value
If (Me.TM) Then
ws.Cells(lin, 3) = "2"
Else
ws.Cells(lin, 3) = "3"
End If
ws.Cells(l, 4).Value = Me.group.Value
ws.Columns("A:D").AutoFit
Me.title.Value = ""
Me.nidaula.Value = ""
Me.TM.Value = False
Me.TC.Value = False
Me.group.Value = ""
Me.title.SetFocus
End Sub
Welcome to Sopt. To make it more legible, you could use this tool of indentation for VBA? And could provide information on how the data is in ADAE Spreadsheet and colunax A and B, where the error occurs? It can be image or preferably a table to reproduce the error.
– danieltakeshi