Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Search for cells that DO NOT contain specific text

Hi,

I am trying to write a macro that checks each row for a specific text in a
column.
If it does not contain the text, I want to hide the row.
....BUT only if checkbox1 is checked (true).

I thought it would be something like the below, but I don't have it right....

I am doing this within a For...next loop.

If Cells(RowNumber, SearchColumn) < "*SPECIFIC TEXT*" And CheckBox1
= True Then
'Select row
Rows(RowNumber).Select
'Hide row
Selection.EntireRow.Hidden = True

Any help appreciated.
Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Search for cells that DO NOT contain specific text

Hi,

Maybe this

searchcolumn = "A"
For rownumber = 1 To 10
If InStr(Cells(rownumber, searchcolumn), "SPECIFIC TEXT") < 1 And
CheckBox1.Value = True Then
Rows(rownumber).EntireRow.Hidden = True
End If
Next

Mikr

"HowOnEarthDoI" wrote:

Hi,

I am trying to write a macro that checks each row for a specific text in a
column.
If it does not contain the text, I want to hide the row.
...BUT only if checkbox1 is checked (true).

I thought it would be something like the below, but I don't have it right....

I am doing this within a For...next loop.

If Cells(RowNumber, SearchColumn) < "*SPECIFIC TEXT*" And CheckBox1
= True Then
'Select row
Rows(RowNumber).Select
'Hide row
Selection.EntireRow.Hidden = True

Any help appreciated.
Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Search for cells that DO NOT contain specific text

Try something more like this... (untested)

dim rngToSearch as range
dim rngToHide As range
dim rng as range

if checkbox1 = tue then
set rngtosearch = range(Range("A1"), cells(rows.count, "A").end(xlup))

for each rng in rngtosearch
if instr("SpecificText", rng.value) < 0 then 'you could use like
if rngToHide is nothing then
set rngtohide = rng
else
set rngtoHide = union(rng, rngtohide)
end if
next rng
end if

if not rngtohide is nothing then rngtohide.entirerow.hidden = true

--
HTH...

Jim Thomlinson


"HowOnEarthDoI" wrote:

Hi,

I am trying to write a macro that checks each row for a specific text in a
column.
If it does not contain the text, I want to hide the row.
...BUT only if checkbox1 is checked (true).

I thought it would be something like the below, but I don't have it right....

I am doing this within a For...next loop.

If Cells(RowNumber, SearchColumn) < "*SPECIFIC TEXT*" And CheckBox1
= True Then
'Select row
Rows(RowNumber).Select
'Hide row
Selection.EntireRow.Hidden = True

Any help appreciated.
Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Search for cells that DO NOT contain specific text

Works BEAUTIFULLY!

Thanks, Mike.

Thanks, Jim, also - really appreciate the quick responses.


"Mike H" wrote:

Hi,

Maybe this

searchcolumn = "A"
For rownumber = 1 To 10
If InStr(Cells(rownumber, searchcolumn), "SPECIFIC TEXT") < 1 And
CheckBox1.Value = True Then
Rows(rownumber).EntireRow.Hidden = True
End If
Next

Mikr

"HowOnEarthDoI" wrote:

Hi,

I am trying to write a macro that checks each row for a specific text in a
column.
If it does not contain the text, I want to hide the row.
...BUT only if checkbox1 is checked (true).

I thought it would be something like the below, but I don't have it right....

I am doing this within a For...next loop.

If Cells(RowNumber, SearchColumn) < "*SPECIFIC TEXT*" And CheckBox1
= True Then
'Select row
Rows(RowNumber).Select
'Hide row
Selection.EntireRow.Hidden = True

Any help appreciated.
Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Search for cells that DO NOT contain specific text

Glad I could help

"HowOnEarthDoI" wrote:

Works BEAUTIFULLY!

Thanks, Mike.

Thanks, Jim, also - really appreciate the quick responses.


"Mike H" wrote:

Hi,

Maybe this

searchcolumn = "A"
For rownumber = 1 To 10
If InStr(Cells(rownumber, searchcolumn), "SPECIFIC TEXT") < 1 And
CheckBox1.Value = True Then
Rows(rownumber).EntireRow.Hidden = True
End If
Next

Mikr

"HowOnEarthDoI" wrote:

Hi,

I am trying to write a macro that checks each row for a specific text in a
column.
If it does not contain the text, I want to hide the row.
...BUT only if checkbox1 is checked (true).

I thought it would be something like the below, but I don't have it right....

I am doing this within a For...next loop.

If Cells(RowNumber, SearchColumn) < "*SPECIFIC TEXT*" And CheckBox1
= True Then
'Select row
Rows(RowNumber).Select
'Hide row
Selection.EntireRow.Hidden = True

Any help appreciated.
Thanks.

Reply
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
Nested formula to search a text string and return specific text Barbie Excel Worksheet Functions 10 February 21st 09 07:40 AM
Looking for a way to search for specific text across columns dathomas Excel Worksheet Functions 2 October 5th 06 08:30 PM
search column of text cellto identify those cells with specific w Ross Headifen Excel Worksheet Functions 1 July 8th 06 02:49 PM
How do I search for specific text and sum the cell to the right? PacRat2001 Excel Worksheet Functions 3 October 12th 05 04:21 AM
Excel Macro Query - Search for specific text in cells of a column Mcneilius Excel Programming 2 August 29th 04 05:12 PM


All times are GMT +1. The time now is 06:09 AM.

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

About Us

"It's about Microsoft Excel"