2

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
  • 1
    In future, please include your code in the question, not just a picture of your code. (In this case the mistake was so obvious that people didn't need to debug the code, but usually people need to be able to copy/paste your code into their computer in order to test it, and they shouldn't be forced to retype it before they can help you.) Commented May 28, 2017 at 19:24

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.