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
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:
That code looks fine to me, Cells(MyVariable, 10) should refer to J5 on the active sheet.

What problems are you having?
Keyboard CowboyCommented:
for one thing, you need and end if (perhaps that got cut off).  You don't really need .value
This worked for me
Sub test()
Dim n As Integer
n = 5

If Cells(n, 10).Value = "" Then
    MsgBox "empty"
    End If
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Keyboard CowboyCommented:
Of course - this also works on a single line
If Cells(n, 10).Value = "" Then MsgBox "empty"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.