#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Find syntax

Hi all

I have code that works fine to search through a worksheet row by row, locate
a string anywhere in a row and, if found, copy that entire row to a different
worksheet:

For r = firstRow To lastRow
Set c = Rows(r).Find("M123")
If Not c Is Nothing Then
Rows(r).Copy
Sheets("SubData").Activate
Range("A65000").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
Range("A65000").End(xlUp).Offset(0, 0).PasteSpecial (xlPasteFormats)
Sheets("AllData").Activate
End If
Next r

However, I need to amend this so the search for a string is only carried out
on one particular column of each row (column K). I've tried all sorts of
permutations of the find syntax without success. Can anyone help please?

Many thanks
Sue
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Find syntax

Hi Sue,

Try

Set c = Intersect(Rows(r), Columns("K")).Find("M123")



---
Regards,
Norman



"SueJB" wrote in message
...
Hi all

I have code that works fine to search through a worksheet row by row,
locate
a string anywhere in a row and, if found, copy that entire row to a
different
worksheet:

For r = firstRow To lastRow
Set c = Rows(r).Find("M123")
If Not c Is Nothing Then
Rows(r).Copy
Sheets("SubData").Activate
Range("A65000").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
Range("A65000").End(xlUp).Offset(0, 0).PasteSpecial
(xlPasteFormats)
Sheets("AllData").Activate
End If
Next r

However, I need to amend this so the search for a string is only carried
out
on one particular column of each row (column K). I've tried all sorts of
permutations of the find syntax without success. Can anyone help please?

Many thanks
Sue



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
find syntax help please Gary Keramidas Excel Programming 3 October 18th 06 12:08 AM
Correct find syntax cereldine[_42_] Excel Programming 1 July 5th 06 05:08 PM
Excel97 - Syntax for Find, Offset, Insert Page djh Excel Programming 2 October 5th 05 02:36 PM
Find method syntax Stefi Excel Programming 4 July 27th 05 02:19 PM
Macro syntax - how to find them mike b Excel Programming 1 April 11th 05 06:18 PM


All times are GMT +1. The time now is 01:00 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"