Excel VBA ByRef argument type mismatch

2019-07-13 06:43发布

I am trying to write a procedure that captures when a cell has been selected and simply returns the cell column and row. I am getting a 'ByRef argument type mismatch' error but it doesn't make sense. See below screenshot:

enter image description here

The issue seems to be with the iRow variable. As far as I can see it is an integer and never ceases to be an integer. Why is the compile error occurring?

Please help. This is driving me crazy.

1条回答
Evening l夕情丶
2楼-- · 2019-07-13 07:32

That is because you have declared iRow as Variant. Unlike VB.Net, you will have to declare all variables explicitly. Anything which is not declared will be taken as a Variant

Change the line

Dim iRow, iCol As Integer

to

Dim iRow As Integer, iCol As Integer
查看更多
登录 后发表回答