View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Find Text in Cell and Copy

OK. I guess I'm a tad bit lost. This finds the information but how do it get
it to provide and extract the information I want found? Out of that Data
string the end result I want extracted for me to use is "QT-WR9395.0435"

How can I get that one particular restult to be able to be used instead of
just identifying that it is there?

Sorry for not understanding how to do this. :(

"Joel" wrote:

You need to add code to get data from cells such as code below. I just
showed how to extract the strings from the data.

for Rowcount = 1 to 100
Data = Range("A" & RowCount)
'my code
next Rowcount



"Rob" wrote:

Thanks for the reply. But I do not understand the "Data" portion of this.
The "Data being searched through is going to always be different from one
cell to another. It looks like with tat "Data" portion it only allows for
just the one. Is that correct? How can I make this to search other cells
insead of just the one?


Thanks Very Much Again.



"Joel" wrote:

Try something like this

Sub SeperateString()

SearchStr = "QT-WR"
Data = "Q-6464694_QT-WR9395.0435_8586-44.05950.3_QT-WR9395"
Do While InStr(Data, "_") 0
FirstID = Left(Data, InStr(Data, "_") - 1)
Data = Mid(Data, InStr(Data, "_") + 1)
If Left(FirstID, Len(SearchStr)) = SearchStr Then
'enter Your code here
End If
Loop

'Add more code here for last item

End Sub


"Rob" wrote:

Hello,

I am trying to find some sort of code that will ease the pain of my task.
What I am needing to do is find a certain string of text within a cell and
copy it to another cell. The catch is that the text is variable in it total
content but the info I need is similar but not exactly the same nearly all
the time. Example below.

The text in cell (B2)...
Q_6464694_QT-WR9395.0435_8586-44.05950.3_QT-WR9395

There are litterally thousands of cells with similar text but the length of
it and the contect is variable.

What I need from it for cell (A2)...
QT-WR9395.0435

The "QT-WR" is always the same but the "9395" is variable in text and
length. The "." is always there somewhere and the "0435" is variable in text
only.


Is there a way to code something that looks for the QT-WR and grabs that
plus everything after it until the forth caracter after the "."? I tried to
use the Left and Right but I could not figure out how to make it give me the
right info since the text length is not always the same.


Thanks in Advance,
Rob