Can I use variables in a Range function?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I´m triyng to use a variable content in a Range function without success,
Example:

LINHAREF = 10
Do While LINHAREF < 40
Lk = "K" + Str(LINHAREF)
MsgBox Range(Lk)
LINHAREF = LINHAREF +1
Loop
 
You've DIMmed LINHAREF as an Integer, right?

Change it to: Lk = "K" & LINHAREF

Works for me.
 
You can also use cells().

LINHAREF = 10
Do While LINHAREF < 40
MsgBox cells(linharef,"K").value
LINHAREF = LINHAREF +1
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top