I am a beginner in coding and I was doing a course of VBA, when suddenly while trying to do an excersice this error prompted: error 1004 in the method of 'Range' of the object 'Global' so I was wondering if someone could give me a hand.
Thanks for reading, and sorry if your eyes hurt with the code.
Private Maxima As Integer
Private Sub lblCódigoClientes_Click()
End Sub
Private Sub UserForm_Initialize()
Inicializo
End Sub
Public Sub Inicializo()
Dim Rango As Range
Dim Maxima As Range
UltimaFila = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
txtNombre = ""
txtApellido = ""
txtTelefono = ""
txtEmail = ""
If UltimaFila = 5 Then
lblCodigo.Caption = 1
Exit Sub
End If
Set Rango = Range("B6:B", Trim(Str(UltimaFila)))
Set Maxima = Rango.Find(Application, WorksheetFunction.Max(Rango), LookIn:=xlValues, LookAt:=xlWhole)
valor = Maxima.Value
lblCodigo.Caption = valor + 1
End Sub