Jenkins
asked on
Reference a cell using a variable
I'm trying to use a variable value in a macro to reference a cell. For example, I currently some code that looks like this:
If Cells( 5,10).value = "" then
msgbox "cell J5 is empty"
Let's say I have an Integer variable named MyVariable and I assign a value of 5 to it.
I'm trying to code something like:
If Cells(MyVariable,10).Value = "" then
msgbox "cell J5 is empty"
but I can't get it to work. I don't care about using the "Cells" reference method. I'm just trying to use any method where a cell can be referenced using a variable like the one I've drescribed above.
Thank you
If Cells( 5,10).value = "" then
msgbox "cell J5 is empty"
Let's say I have an Integer variable named MyVariable and I assign a value of 5 to it.
I'm trying to code something like:
If Cells(MyVariable,10).Value
msgbox "cell J5 is empty"
but I can't get it to work. I don't care about using the "Cells" reference method. I'm just trying to use any method where a cell can be referenced using a variable like the one I've drescribed above.
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Of course - this also works on a single line
If Cells(n, 10).Value = "" Then MsgBox "empty"
If Cells(n, 10).Value = "" Then MsgBox "empty"
What problems are you having?