# Returning Row Numbers Where One Word Contained In Text String - Multiple Occurrences

Oct 30, 2013

I am trying to identify the row(s) where a match occurs when there can be multiple occurrences of the match.

A
B
C

1
john brown
Brown
True

2
Cathy Smith

3
Brown excavating company

4
XYZ Corp

5

The first test I ran in cell C1 with the information above was to determine if "Brown" was located in the range of A1:A5 using formula:
=IF(ISNUMBER(MATCH("*"&B1&"*",A1:A5,0))=TRUE,"True","False")

In the case of the word "Brown" it occurs in the range of A1:A5 three times, so the result of the above formula would be "True"

Now what I would like to do is return the locations, in this case the row number(s), where the word brown is contained range of A1:A5 because in the case of the word Brown, it occurs three separate times in the range of A1:A5. I would like the resulting value of the formula in this case to be "1, 3, 5" indicating the word Brown occurs in rows 1, 3, and 5. The formula also needs to work in case there is only one match as well.

I tried using the below array formula:
={MATCH(FALSE,ISERROR(SEARCH(B1,'Working List of Vendors'!\$A\$1:\$A\$5)),0)}
But it would only return the first occurrence of the match which in this case would be row 1, or "1"

## Count Word Occurrences In String

Jan 5, 2007

Lets say there is a string: " andy,andy,tom,amy,andy" and I would like to search the word "andy". The function would return 3.

How could I implement this using VBA?

## VLookup For Numbers Contained Within Cells With Numbers And Text

Sep 26, 2012

A
B
C
D
E
F
G
23445566894 Brwn pdc aft
Cat1
45687930596
\$5
Cat2
23445566894
\$6

In the example above, I would like to do a vlookup in column C that matches the digits in column A to those in column F, with the output being the corresponding value in column G. I believe it involves the left function but not sure how to really use it here.

## Counting Occurrences Of Text String

Dec 11, 2006

I have a spreadsheet which consists of Sheet 1 and Sheet 2.

In Sheet 1, Column I there is a list of country names which indicate who visited our website at a certain time. So for example England may be listed multiple times.

In Sheet 2 I have a table showing January through to December in a column and the different country names across the top in one row.

I want the Table in Sheet 2 to count how many times England (for example) occurs in Column I and to indicate that as a numeric value.

## Loop And Parse All Occurrences Of Text After Text In A String

Nov 29, 2011

I am working on modifying this code (below) that I found here: VB Macro to search webpage for text string

Code:

Option Explicit
Public stResultstr As String
Sub SearchForString()
Dim rngURL As Range
Dim cll As Range
Dim stCheck As String
Dim xmlHttp As Object

[Code]...

So right now I have the script prompt you for a URL range, then it asks you for what you want to search for, and I have it set to return the next 10 characters from that found point.

You can see here:

Code:

If InStr(1, stResult, stCheck, vbBinaryCompare) > intt Then
intt = InStr(1, stResult, stCheck, vbBinaryCompare) + Len(stCheck)

I began to create something to identify the last position of the found item because next I want to loop it to find the next occurance of the same thing and return the next 10 characters after it in the next cell to the right in that same row:

Code:

cll.Offset(, 1).Value = stResultstr

Again, what I want to do here is find and parse out every occurence of a string (inputbox) found on a web page url in column A. The parse occurrences will go to the right in cells C though ? for row N.

## If Word Is Contained Within A Cell, Ouput That Word In Another

Jul 18, 2008

I have a bunch of cells in column b that have products.

Column B
Dell 24" lcd
vaio sony laptop
8.0 mpxl kodak camera
photoepsonprinter

Basically in Column A I want a formula that'll say.

If the word "dell" is somewhere in cell b1, then put the word "Dell" in cell a1.
If the word "sony" is somewhere in cell b1, then put the word "sony" in cell a1.

And then so on and so forth down through column A. The brand names are potentially endless, so is there a easy way to on like a seperate sheet make a list of brand names and have it pull from there?

Originally I made a if function that said if the brand name was contained in the cell then output the brand name, but that caps at 7 for the amount of brands i can use....

## Formula To Count Occurrences Of Multiple Elements Within A String

Oct 9, 2009

I have a number of records that have in one cell a string of the form 1,2,3 etc (up to 10) representing conditions that have been met. There are a number of options available for producing reports on all of the other attributes in a record but now we wish to add this element as well.

The reports I can produce using VBA and the INSTR function, however on the summary page where, a total of all records matching available criteria is shown, depending upon drop down items being selected, I need to add this element to the equation as well. The existing conditions are counted using SUMPRODUCT and a combination of IF statements and work fine.

As there is an option to create a report for both AND and OR, e.g. if condition 1 and 2 and 3 apply include in the report, or if condition 1 or 2 or 3 apply include in the report

The conditions are selected using a check box and a drop down list to select the AND/OR condition.

I have been trying various combinations of database functions, countif, find and cannot get them to evaluate. I suspect that it may be beyond my reach to use a formula and I will need to use VBA with a Worksheet_Change macro to achieve what I want, or alternatively redesign the layout to store the conditions differently, however if anyone has any ideas for a formula I would much appreciate hearing from you.

A sample worksheet illustrates how the data is currently shown. The string in the record column is created using VBA and then inserted into the actual record.

## Returning Number From Text String

Jul 24, 2007

I have been trying a few formulas to return numbers from a string of text. The problem I am having is that there are more than one set of numbers that I need returned.

Here is an example of the text entered in F2

"K2PT bus structure [2 locations] & strain structure South West of L9L12-12 [1 location] / Use #4/0, std, cu conductor, connector Cat ID#10842 at structure leg & connector Cat ID#9655 at #4/0, std, cu gnd loop to connect #4/0, std, cu gnd loop to str leg."

What I need returned in a cell H2 is the numbers beside the Cat ID#

10842, 9655

I tried a Return Right Value formula, but I think because there are more than one possible value it isn't working properly.

## Returning String From One Cell Based Upon Multiple Cells

May 22, 2013

I need to return the specific text of a cell based upon the text in multiple cells.

Worksheet as follows:

Asphalt Sub:
BLDG1-Backwash 1
*BLDG1*
*Sub*
BLDG1-Backwash 1 OverEx
*BLDG2*
*Sub*

[Code].....

I have three columns thus far. I need to add another column and search all items in Column A using the criteria in Columns B and C. For instance I need to search for BLDG1-Backwash Sub: and place it into column D using the criteria in Columns B and C.

If possible, I would also like to remove both the words, BLDG1 and Sub from the result so then it only shows "Backwash".

My spreadsheet is much larger than this and I have muliple buildings I am dealing with, sometimes 30-40.

## Extracting Word From Text String

Sep 11, 2013

I have random text strings which I need to extract the last part from in Excel.

The text string will be made up of code, but the word I need is always to the right of a prefix />

So for instance in A1 I have 76ruihfo:;.>6">/apple

I would want to extract "apple" from the string above into B1.

## Formula To Add All Of Times If Text String Contains Word

Jun 11, 2013

I currently have a large amount of data extracted from a performance tracking system. The columns I am concerned with are Page Title and Time (the time it takes the system to navigate to the this page).

I am trying to create a dashboard to show:

Webpage Title (each unique instance of the webpage)Aggregate Time (total time it takes for all instances)# of Hits (Each time the value appears in the data)Average Time (this formula I can handle; Aggregate Time/# of Hits)

The major issue is that the webpage is extracted as XYZ001 -- PAGE1, XYZ439 -- PAGE2, XYZ854 -- PAGE1, etc. Basically, I am only concerned with what comes after the --.

Here is an example of the two tabs.

DASHBOARD TAB:

Page Title
Aggregate Time
# of Hits
Avg. Time
PAGE1

[Code]...

Basically, I am looking for a formula that says,

For any instance in the Page Title column that contains PAGE3, add the amount in the Time column (i.e., 1.2 +.5).

## Web Query Returning Text But Not Numbers

Oct 3, 2009

I have this web query to retrieve Stock Market data for individual scrips which used to work fine till 2 weeks ago:
[url]

Since then all it returns is the text in the tables. Numbers eg dates and stock prices come as blanks.

These show up alright in the browser (Mozilla as well IE).

Some other tables at this site plugged into query return complete data. eg [url]

I tried many different scrips with same results.

Since it was working fine till 2 weeks ago AND other tables at this site are working fine, I suppose the site changed something.

## Count Number Of Occurrences Of Multiple Strings In Two Text Files

Jun 11, 2014

In Column A I have the list of strings that I need to search. I want to count the number of occurrences of these strings inside these two text files: Sample1.txt and Sample2.txt. For example I have the string "DOG". I want to search and count the number of times this string appeared in Sample1.txt, and Sample2.txt

See below:

## Formula To Extract Word Out Of Text String In Cell?

May 7, 2014

I have a long list of process steps in a collumn e.g.

A
_Tank1_CIP
_Tank1_CIP
_Tank2_CIP
_Tank4_CIP
_Tank_9_CIP

and then i have a list of tanks: Tank1, Tank2 etc. The i want a forumla to extract and return the tank in a adjacent cell:

A B
_Tank1_CIP Tank1
_Tank1_CIP Tank1
_Tank2_CIP Tank2
_Tank4_CIP Tank4
_Tank_9_CIP Tank9

## Pull Specific Word From String Of Text In Cell?

May 16, 2004

I need to pull a specific word from a string of text in a cell and have that word shown in an adjacant cell. For example A1 will contain the text "Smith Sun Alliance Pension Fund" I need B2 to show "Pension". I cannot use any filtering or text to columns as the word Pension can be anywhere within the text in A1 and I have thousands of entries. So I need a function.

## Function: Selected String Contained Certain Phrases

May 13, 2008

I wrote this function to see if a user selected string contained certain phrases. It keeps returning united states so i am guessing its not cycling through the entire list.

Function region2(searchString As String)
Dim result As String
result = "None"
Dim lng() As String
lng = Array("arabic", "belg", "bul", "czech", "dan", "dut", "dutch", "euro", "finnish", "french", "ger", "greek", "greenland", "hebrew", "hung", "iceland", "international", "ital", "nor", "pol", "portu", "russ", "slov", "spanish", "swe", "swi", "turk", "UK", "united kingdom", "states")

Dim Country() As String..........

## Find Unknown Char Contained In A String And Store It In Variable

Jun 4, 2013

I need to store a known index, unknown value in a variable so I can increase the value and use it in a database. It is used as a version number for a part and the versions go like: "00" -> "AA" -> "AB" -> .... -> "AZ" -> "BA"... etc.

VB:
If tool.Worksheets("TRB Database").Cells(A, "R").Value <>
ThisWorkbook.Worksheets("Design Calculator, Q").Cells(7, "C").Value Or
tool.Worksheets("TRB Database").Cells(A, "AA").Value <>
ThisWorkbook.Worksheets("Design Calculator, Q").Cells(5, "K").Value Or tool.Worksheets("TRB Database")

[Code] ....

That is a part of the increase and when I try to increase "AA" by 1 it goes to "B" and not "AB".

VB: tool.Worksheets("TRB Database").Cells(row1, "D").Value = Chr(Asc(tool.Worksheets("TRB Database").Cells(A, "D").Value) + 1)

This is where I increase the value.

## Extracting Phone Numbers From Text String Variation In Preceding Text

Mar 29, 2013

I'm pulling phone numbers out of text strings. There is text string ("Office:") indicating that the number following is an office number (the number that I need). MID and FIND take care of this. There are sometimes two instances of office numbers in single text string, so adding a second column using the third argument of FIND lets me start another search past the first instance of an office number. We have a bunch of office numbers with the qualifier "(Text)" after the original "Office" but before the phone number. How do I catch these ones?

## Pasting List Of Text And Numbers From MS Word

Jan 17, 2010

I have a very large list of top scorers for a sports team MS Word. The name and number of goals are both on the same line. Is there any possible way I can past them into Excel, so as they are pasted into 2 separate columns?

## Count Word Occurrences But Excluding Keywords?

Feb 13, 2014

I have a list of courses that are run each month, I have a formula that counts the occurrences of these words to show how many times each course is run per month.

However, there are 'other' courses that will be run adhoc which I want to count the occurrences of. It basically needs to count if there is text there but exclude the normal courses which are run.

I have attached a spread sheet as an example, the list of the normal courses are on the right. I've highlighted in yellow where I need the formula.

## Having 1 Column Add Up Word Occurrences From 2 Other Columns And Sort?

Sep 20, 2013

So, I have two columns on a sheet that all contain drop down boxes for various information. We'll refer to them as column 1 and column 2.

In column 3, I want to have the highest instances of those words sorted with the highest on top, and downward from there, along with the number of times it appears in either column 1 or 2. (And I want the sorting to be dynamic, i.e. when I change what's in column 1 or 2, it will re-rank them according to highest number)

i.e.

Column1 Column2 Column3 (Column4-#)
Bob Tom Bob 5
Joe Bob Tom 2
Bob Joe 1
Tom Bob
Bob

I have the drop downs and what not for the 1st 2 columns, I just need to know how to make 3 & 4 happen.

## SUMIF/COUNTIF- Several Numbers That Are Contained In Non-adjacent Cells

Jan 9, 2008

I have several numbers that are contained in non-adjacent cells. I need to create a cell that will evaluate the cells individually to make sure that they are within a certain range. Once that is done, I want the remaining numbers that are within the range to be averaged. How the heck can I accomplish this task? SUMIF and COUNTIF will not allow me to use non-adjacent cell ranges.

## Extract Numbers After Text In Text String

Mar 12, 2014

I am trying to extract numbers after a specific text in a text string, for eg :abc SN 12345 xyzedf SN No. 456 mnoAs per above, i want to extract any numbers afters "SN". the numbers can be vary in digits i.e. it can be 3 digit numbers or 4 or 6. Also, at times there is some other text in between (like SN No.) numbers and search word (i.e. SN)Any formula to get result as "12345" and "456".

## Sum Numbers From Text String

May 21, 2014

I am struggling with a problem which involves a column with both the text and nos in that. I want to calculate the following formula.

Total = the Sumproduct of the nos in the description*Length*Width*Height.

In the description column,
1) The nos will be varying i.e x*x or x*x*x or X*x*x*x*.
2) After the nos there will not be any data.

Example table:
Work Description

Length
Width
Height
Total

Parapet wall 2x4x8
12
2
4
6144

[Code] .......

Is there a way to achieve this, what is the formula for this ??

## Find A Certain Word In A String Then Return The Number Associated With That Word

Jun 9, 2009

Have problems using find and the Dictionary
What Im trying to do is find a certain word in a string then return the number associated with that word

## Finding Numbers In Text String

May 11, 2010

In a data report i have a column which contains a mix of text and may contain an 8 digit number which could start in 0.

for example

in column A i could have "Hello how are you 01237232 I am fine"

I wish to extract the number into a seperate column, and would ordinarilly use a mid or left/ right function, however the text infront and behind the number will vary in length, which means i cannot do this.

The number will always be 8 digits, could start in 0 but will not always, and it may not be present in all the cells in this column.

How I an achieve this?

## Extract Numbers From Text String

Sep 24, 2009

I have several lines with text strings containting three numbers in each line. I need a code to extract all three numbers from each text string. The numbers can be placed on the following columns in each row.

## Separate Text From Numbers In A String?

May 30, 2002

Is there a way to separate text from numbers, (other than text to columns)

My data is all different lengths, nothing consistent,plus I want to put the separated data in another column.

## Separate Text From Numbers In A String

May 30, 2002

Is there a way to separate text from numbers, (other than text to columns)
My data is all different lengths, nothing consistent,plus I want to put the separated data in another column.

## Extracting Both Numbers And Text From A String

Jun 21, 2007

I have a woorkbook where I have a cell that has the following apperance:

12345678-ABCDEFG

The numbers can vary in length and as well as the text. What I am trying to do is to split this cell into to columns. Column 1 shows the account number, Column 2 should show the Text and the "-" sign should not be in any of the columns ie it should look something like this

Column1 Column2
12345678 ABCDEFG

I have found a useful function for the first part thanx to Mikerickson
URL:Extract Numerical Data

Function midNumber(inputStr As String) As Double
Dim i As Long
For i = 1 To Len(inputStr)
midNumber = CDbl(Val(Mid(inputStr, i)))
If midNumber <> 0 Then Exit Function
Next i
End Function

But how do i seperate the text and how do Crete a macro that would loop through some 2000 rows and create a column A and B from Column A?