Search for data in Excel and hide rows

  • Thread starter Thread starter Bjarne Jensen
  • Start date Start date
B

Bjarne Jensen

Hi newsgroup,

Has come upon an interesting challenge ;-)

I have to search through an Excel sheet for a lot of data. I would like to
have the rows without the searched data to be hidden. Is it possible to do
that in Excel - or is it something like a VBA script?

Inputs are welcome.

I use MS Excel 2007, English

Thanks in advance.

/ Bjarne
 
Hi,
An example might help, however if you want to select some data you can use
filters, which will show you only the data filtered
 
Excel way:
Place an autofilter on your data, and do a custom filter of:
"does not equal", My Data

VBA:

'=============
Sub HideRows()
For each c in Range("D1:D100")
if c.value <> "My Data" then
c.EntireRow.Hidden = True
else
c.EntireRow.Hidden = False
end if
next
End Sub
'===============

Note that the XL way would be faster performance time, while VBA would be
nice if you need to string multiple criteria together.
 
Back
Top