Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default sniffing out string inside cell

I am setting a specific range (A1:F29) and need to determine if a cell
contains a specific string, "CV7". This string an extension/suffix of a
larger string. If the string in the cell exists I would like to copy the
value of the cell and place it in a separate worksheet, worksheet 2. If the
string does not exist we should move on to the next cell within the range.

I am not sure how to sniff out the specific string.

Thanks,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default sniffing out string inside cell

sub copyData()
Dim cell as Range, rw as Long
rw = 2
for each cell in ActiveSheet.Range("A1:F29")
if instr(1,cell,"CV7",vbTextcompare) then
worksheets("Sheet2").Cells(rw,1).Value = cell.Value
rw = rw + 1
end if
next
End sub

--
Regards,
Tom Ogilvy


"Pablo" wrote:

I am setting a specific range (A1:F29) and need to determine if a cell
contains a specific string, "CV7". This string an extension/suffix of a
larger string. If the string in the cell exists I would like to copy the
value of the cell and place it in a separate worksheet, worksheet 2. If the
string does not exist we should move on to the next cell within the range.

I am not sure how to sniff out the specific string.

Thanks,

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default sniffing out string inside cell

Look at:

Sub pablo()
Dim r1 As Range, r2 As Range
Set r1 = Sheets("s1").Range("A1:F29")
Set r2 = Sheets("s2").Range("A1")
For Each r In r1
If InStr(r.Value, "CV7") < 0 Then
r2.Value = r.Value
r2.Offset(0, 1) = r.Address
Exit Sub
End If
Next
End Sub


We look for CV7 in sheet s1. If it is found, the contents of the cell are
deposited in cell A1 in sheet s2.

I also put the address where the data was found in cell B1. You can remove
this if you don't need it.
--
Gary's Student
gsnu200704


"Pablo" wrote:

I am setting a specific range (A1:F29) and need to determine if a cell
contains a specific string, "CV7". This string an extension/suffix of a
larger string. If the string in the cell exists I would like to copy the
value of the cell and place it in a separate worksheet, worksheet 2. If the
string does not exist we should move on to the next cell within the range.

I am not sure how to sniff out the specific string.

Thanks,

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default sniffing out string inside cell

Tom & Gary

Thank you very much. This saved a lot of time.

"Tom Ogilvy" wrote:

sub copyData()
Dim cell as Range, rw as Long
rw = 2
for each cell in ActiveSheet.Range("A1:F29")
if instr(1,cell,"CV7",vbTextcompare) then
worksheets("Sheet2").Cells(rw,1).Value = cell.Value
rw = rw + 1
end if
next
End sub

--
Regards,
Tom Ogilvy


"Pablo" wrote:

I am setting a specific range (A1:F29) and need to determine if a cell
contains a specific string, "CV7". This string an extension/suffix of a
larger string. If the string in the cell exists I would like to copy the
value of the cell and place it in a separate worksheet, worksheet 2. If the
string does not exist we should move on to the next cell within the range.

I am not sure how to sniff out the specific string.

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
Need macro to insert text string while inside cell (formula) BrianB Excel Discussion (Misc queries) 0 May 31st 05 03:18 PM
reading inside a text string ksnapp[_10_] Excel Programming 4 February 27th 04 09:55 PM
find a string inside another string MarkS Excel Programming 1 January 13th 04 02:55 AM
Check if a String is inside an Array Dave Peterson[_3_] Excel Programming 3 September 3rd 03 08:41 PM
Check if a String is inside an Array Alan Beban[_3_] Excel Programming 0 September 3rd 03 07:44 PM


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