Link to home
Start Free TrialLog in
Avatar of onesegun
onesegunFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Using xlDown method for visible cells to set range object

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
ASKER CERTIFIED SOLUTION
Avatar of nutsch
nutsch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of onesegun

ASKER

Hi patrickab,

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

Thanks,

OS