Select i Rows

  • Thread starter Thread starter daniroy
  • Start date Start date
D

daniroy

I wish to select a line i with i defined as
For i = 2 To Last_Row(Sheets("Stocks").Columns("A:A")) + 1

I wrote

Rows("i:i").Select

but it is not working. I am dumb. I still dont understand this story
of brakets, could someone take two minutes to explain it to me or tell
me where should I look, please?
Kind regards
Daniel
 
I'll try:

For i = 2 To LastRow

i will equal an integer, so the first occurence using Rows("i:i") would
translate to Rows("2:2") which is syntax not recognized by VBA. If you used
Rows(i) it would translate to Rows(2) and would be recognized as the correct
syntax.

For a more detailed explanation, open the VB editor (Alt+F11) and click on
help. Type "Referring to cells" in the search box and you will see three or
four references there that explain the different sytax used in refrerring to
cells and ranges of cells.
 

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