Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trying to find string in a column or row

Hi,

Currently I have code that functions properly - but I'm sure there ha
to be a better way of coding! :-)

Basically - whenever I search for a string in a column or row - righ
now - I use a For Loop until rng.Rows.Count or rng.Columns.Count - an
then inside my loop I query to see if a cell contains the cell valu
I'm looking for..... for example

For i = 1 to rng.Rows.Count
If ws.Cells(i, 1).Value = "xyz" Then
MsgBox("Found string")
End If
Next i

Is there better way to code this ? - where I can say something like:

If rng.Rows.Contains("xyz") Then
MsgBox("Found string")
End If

Thanks in advance!
-Robi

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trying to find string in a column or row

if application.Countif(rng.EntireRow,"xyz") 0 then

--
Regards,
Tom Ogilvy

strataguru wrote in message
...
Hi,

Currently I have code that functions properly - but I'm sure there has
to be a better way of coding! :-)

Basically - whenever I search for a string in a column or row - right
now - I use a For Loop until rng.Rows.Count or rng.Columns.Count - and
then inside my loop I query to see if a cell contains the cell value
I'm looking for..... for example

For i = 1 to rng.Rows.Count
If ws.Cells(i, 1).Value = "xyz" Then
MsgBox("Found string")
End If
Next i

Is there better way to code this ? - where I can say something like:

If rng.Rows.Contains("xyz") Then
MsgBox("Found string")
End If

Thanks in advance!
-Robin


---
Message posted from http://www.ExcelForum.com/



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
EXCEL function;find string in entire column & return cell referenc Audit Compliance Man Excel Worksheet Functions 2 April 21st 23 10:24 AM
Find a text from a column in a text string within another column? Mike Garcia[_2_] New Users to Excel 1 October 22nd 08 06:50 PM
Find a string within a column Rookie_User Excel Discussion (Misc queries) 8 March 17th 06 02:12 PM
Macro to find text string in a column and paste data in another nicolascap Excel Discussion (Misc queries) 8 March 14th 06 03:13 PM
Find text string in column? Dave Peterson Excel Discussion (Misc queries) 3 August 26th 05 01:22 AM


All times are GMT +1. The time now is 06:24 PM.

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"