Solved

Using xlDown method for visible cells to set range object

Posted on 2011-02-16
3
1,049 Views
Last Modified: 2012-05-11
Hi Experts,

I suspect that the method that I am using to set a range object is not working properly because I am getting unpredictable results.

I'm trying to use the statement below in a filtered table but I am only interested in looping through the visible cells.
ActiveWorkbook.Sheets("DropDown_Controls").Range(ActiveCell, ActiveCell.End(xlDown)) 

Open in new window

I suspect something is wrong because the loop carries on past the number of visible cells.

How can I select only the visible cells as a range using the xlDown method?

Thanks,

OS
0
Comment
Question by:onesegun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 50 total points
ID: 34909321
ActiveWorkbook.Sheets("DropDown_Controls").Range(ActiveCell, ActiveCell.End(xlDown)).specialcells(xlCellTypeVisible)
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34915206
xlDown is generally unreliable as it stops when there is a blank cell. Instead it's better to use .cells.rows.count.End(xlup) as that works up from the last row in the worksheet.
0
 

Author Comment

by:onesegun
ID: 34924980
Hi patrickab,

Your point is equally valid btw. In this case there is no possiblity of blanks.

Thanks,

OS
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

705 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