Index/Match range inside of For Each Selected worksheet

Posted on 2011-02-22
Last Modified: 2012-05-11
set wb =
for each wksht in wb.Worksheets
  for i = 2 to myCount
    wksht.Range("C1:T5000") ' This will actually be an index/match

Open in new window

Trying to figure out how to select a range inside of the for each loop of a set of worksheets. Need this for an index/match function that I'm creating, but I'm getting an "Object doesn't support this property or method" error.

Question by:keats88
  • 2
  • 2
LVL 22

Expert Comment

ID: 34956053
Did you try using the select method?


Of course, after you select, you'll need to do something with Selection or it will be a useless task.
LVL 37

Accepted Solution

TommySzalapski earned 125 total points
ID: 34956186
You cannot select a range on an inactive sheet. If you really want to select it you must to wksht.Activate first.
LVL 37

Expert Comment

ID: 34956194
You might need to activate the workbook too.

However, it is good practice to avoid selecting if you can (and you usually can).
LVL 22

Expert Comment

ID: 34956454
Agree with Tommy about selecting.  You can simply reference any cell you want with the Cells method, then the cells are not selected but you can read/write anything you want to them, even on other sheets.

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now