LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default Constrain to visible area?

I have a macro that searchs for a text string and hides any row not
containing the string (code at the end). (I got this from a post on a NG,
and tried a Google search so I could give big credits to the original
author, but I couldn't find the original post.) It works great, with one
small hitch.

If I filter my worksheet to show a range selected from the middle of the
sheet, because it starts from 2, it will search even what is not visible.
Would it be difficult to add some lines to constrain the search area to only
what is visible after filtering? It also does this if I try to run it
twice.

Sub SelectiveRowHide()

Dim myTarget As String
Dim myFind As Range
Dim i As Integer

myTarget = Application.InputBox("What text are you searching for?")

For i = 2 To Range("A65536").End(xlUp).Row
Rows(i).Select
Set myFind = Rows(i).Find(What:=myTarget)
If myFind Is Nothing Then
Selection.EntireRow.Hidden = True
End If
Next i

End Sub


Ed


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chart Area visible but cannot access rows and columns on worksheet Milate2 Charts and Charting in Excel 2 January 23rd 08 01:57 AM
Excel document out of visible area Kamlesh Excel Discussion (Misc queries) 0 October 2nd 07 08:27 AM
Constrain data format in cell Rusty Excel Discussion (Misc queries) 1 March 10th 06 09:58 PM
how to constrain the sum of a range in solver a.raney Excel Discussion (Misc queries) 2 March 10th 06 11:44 AM
column truncated due to width constrain AskExcel Excel Worksheet Functions 1 January 19th 06 03:06 AM


All times are GMT +1. The time now is 11:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"