?
Solved

Using xlDown method for visible cells to set range object

Posted on 2011-02-16
3
Medium Priority
?
1,065 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 200 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

765 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