Thread: Type mismatch
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nigel[_8_] Nigel[_8_] is offline
external usenet poster
 
Posts: 172
Default Type mismatch

It is not that you assignment of the range value (or text) is wrong you
just need to change your last row code to this......

lstrow = Cells(Rows.Count, "A").End(xlUp).Row

Cheers
Nigel

"Patti" wrote in message
...
Can anyone tell me why this produces Run-time error 13: Type mismatch?

Thanks in advance.

----------

Option Explicit
Private Sub testloop()

Dim lstrow As Long
Dim i As Long
Dim agtname As String

lstrow = Range("a" & Rows.Count).End(xlUp).Rows
For i = 2 To lstrow
agtname = Range("a" & i).Value ' *** also tried .Text & still got

error
MsgBox "Current Name is " & agtname
i = i + 1
Next i
End Sub