PDA

View Full Version : Select first non-hidden row below starting cell



Phelony
06-19-2009, 01:42 AM
Any help with this would be greatly apprecaited as it's now driving me nuts. :banghead:

What I've got is a spreadsheet based database (don't ask, they wouldn't let me use something sensible for it) that has a user interface to access the data.

I've got the data being put into the DB, I've got it getting lifted out again for editing, where I'm stuck is putting it back in again.

Each record has a unique reference, so what I'm doing is filtering the appropriate DB page and then looking for the first available unhidden line, which will contain the result.

The new information into each sheet is inserted via a new line at the top of the page so the most recent records show first, which means that the location of the data is constantly changing.

Where I'm stuck :help is, getting the simple code to start at the top of the filtered column and find the first unfiltered cell:

Sub hiddenrowignore()

Range("E1").Select 'starting cell

Do
While ActiveCell > 0
If ActiveCell.Hidden = True Then
ActiveCell.Offset(1, 0).Select

Loop


End If

I keep getting "Loop without Do" and I have a loop and I have a do, what I don't have is a clue what I've done wrong. :bug: The reference that is being filtered against is unique and only one row will come up as a result, they are automatically generated from a master sheet so that no human error can intervene (easily).

Can anyone explain what I've screwed up on in this, or if there is a simpler way of making the selection criteria an active cell to initiate the offset sequence? : pray2:

Thanks

Phel x

PS - I know there are better and easier ways of building a database :mkay

Bob Phillips
06-19-2009, 01:52 AM
Don't you just need an 'End If' before the Loop statement.

Seems an odd way to find the item, why filter, why not just do a Find on the key field?

Phelony
06-19-2009, 01:57 AM
The end if is in the wrong place :( But that still comes up with a "loop without do" message.

I've done it through a filter as the reference it's searching against appears several times in the same row, I need to ensure that the activecell after the search is the same.

A find function wasn't coming up with the same result (as in the same cell) every time and the value I need to search against is produced through a formula drawing from cells A-D.

Are you saying it's possible to do that but to only search the content of one column? :o

Bob Phillips
06-19-2009, 02:25 AM
I haven't tested it, but I would have thought the code should be



Sub hiddenrowignore()

Range("E1").Select 'starting cell

Do While ActiveCell > 0
If ActiveCell.Hidden = True Then
ActiveCell.Offset(1, 0).Select

End If

Loop

And yes, it is certainly possible to search just one column. You specify the range that Find acts upon, that can be a matrix or a vector.