Excel vba : Type range and cell

excelvba

I am bit confused by cell and range in vba (excel).
Logically, i could think a cell as a range with size = 1; and I think it is easy to make a range out of a cell.

If I read the api of EntireRow property here
it operates on range. But, the below code work, indicating 'cell'variable inside the loop is a range

Set import = Sheets("import")
    Set spRange = import.Range("A2")
    Set spRange = import.Range("A2:" & spRange.End(xlDown).Address)
    For Each cell In spRange
        dict.Add cell.Offset(0, 2).Text, cell.EntireRow
    Next cell

At the same time, the below code returns an error indicating type mismatch when call the removecell function. What should be the type of targetCell in the function definition?

Set spRange = mySheet.Range("b2", mySheet.Range("b2").End(xlDown))
For Each cell In spRange
    val = removecell (cell)
Next cell


Public Function removecell(targCell As Range) As Boolean
    removecell = False
End Function

Best Solution

This compiles and runs:

Sub Tester()
Dim spRange As Excel.Range
Dim cell As Excel.Range
Dim mySheet As Excel.Worksheet
Dim val As Boolean

Set mySheet = ActiveSheet
Set spRange = mySheet.Range("b2", mySheet.Range("b2").End(xlDown))
For Each cell In spRange
    val = removecell(cell)
Next cell

End Sub

Public Function removecell(targCell As Range) As Boolean
    removecell = False
End Function
Related Question