Hi

I am trying to generate a random unique number with the following code. The MAX value will be dependant on the number of used rows in another worksheet so Iv tried to allow for this as you can see in the code below.
The problem I have is I'm getting a Compile Error: Constant Expression required.
Iv looked through Google but to be honest a lot of it is over my head.
Could someone help me out please?

Dim i As Long
Dim LastRow As Long

Range("b1").Value = Labelsubject1.Caption

With Worksheets("Questions Round 1")
    LastRow = .Cells(.Rows.Count, "H").End(xlUp).Row
End With
    
'generate random number for subject 1
Static n As Long, s As String
Const MIN = 1, MAX = LastRow, OUT = "A3", DEL = "."
Randomize
Do
    i = Rnd * (MAX - MIN) + MIN
    If 0 = InStr(s, i & DEL) Then
        n = n + 1: s = s & i & DEL
        Range(OUT) = i
        If n > MAX - MIN Then n = 0: s = ""
        Exit Do
    End If: DoEvents
Loop