We help IT Professionals succeed at work.
Get Started

excel vba select range of row with numbers only

codequest asked
Last Modified: 2015-10-31
In statements like this:

dim ws as worksheet
ws = ThisWorkbook.worksheets(1)

ws .Rows([range of rows]).AutoFit


Set myRange =  ws .Rows([range of rows]).EntireRow

how might I specify the [range of rows] using just numbers, instead of the string "R1C4" type construct?

That is, something like this:  


which executes, but then this:


fails with "Select method of range failed", so I can't verify if I really have the range of rows I want in r1.

Any suggestions on this would be appreciated.

Watch Question
Grand Poobah
Most Valuable Expert 2011
Top Expert 2011
This problem has been solved!
Unlock 3 Answers and 12 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE