Editing Using VBA - Find Text Strings In Text File

Dec 7, 2012

I have a large .txt file that I would like to edit using VBA. What I would like to do is to find each of the following text strings in the text file :

De:
De :
Envoye
A:
Objet:

If the character right before those text strings is not a carriage return (chr(13) then add a carriage return.

I would like the code to read each line in the text file and execute the task mentioned above.

View 9 Replies


ADVERTISEMENT

Excel 2011 :: Find Multiple Text Strings In Another Text String

Mar 8, 2013

How do I use an Excel formula to find which (if any) multiple sets, each of up to 50 words, exist in a series of rows of a spreadsheet - if set A has one or more words found in a searched cell.

A positive result will return a specific value in the designated result cell. If none of the words in Set A is found in the searched cell, the formulae will repeat the test for the words in Set B, and so on.

After all 50 sets of words have been tested, the formula will move to the next cell in the searched column.

New words will be added to the sets of words continually as required.

Multiple words within sets are included in double quotes. Within each set of words there will be some n-tuples of words (i.e. 24 adjacent words) that contain one or more of the words in the set, but for which the formula will be required to return a negative result. Example: Set A = word 1, word2, word 3, "word1 word2 word3". (The words within a set could also be each entered in separate columns, as opposed to all included in a single cell.) The single column of text to be searched is about 10,000 rows.

I am wanting to use the above in a spreadsheet that contains data downloaded from a series of bank accounts to automatically allocate items of expenditure to one of 20 or so different categories of expenditure.

The formula will search the description field to find words that are used in the in the downloaded files from the various accounts to describe each transaction.

If a word describing travel expenditure (e.g. hotel, "holiday inn" but not "holiday travel") is found in the description of an expenditure item - the item cost will be allocated to the TRAVEL EXPENDITURE column, which is one of 20 or so different categories of expenditure.

Happy to consider a different solution if the task can be done better a different way.

Tried using a combination of INDEX/SEARCH/IF in Excel, but was not able to get a correct result. PS I am using Excel 2011 for Mac - which does not allow macros, so the solution needs to be entirely formula based.

View 1 Replies View Related

Editing Contents Of A Text File Which Is Delimited

Aug 2, 2009

I have a text file, which has a column of wrong data. I can change it manually by loading it into Excel but it is semi-colon delimited and I can't export to such a file.

I therefore, would like to write a VBA tool, which reads the file and edits the the value between the 5th and 6th semi-colon and will continue do this for each row (the new value is constant across the rows).

View 9 Replies View Related

Find Numbers In Text Strings

Nov 21, 2006

I have several cells in a column that look something like this:

Cell A1: abc 1234 def ghi
Cell A2: xxxx aa b 245 qqqqq
Cell A3: abcdefg hij kl mnopqr s

Is there an excel formula or combination of formulas I can use to identify:
(1) whether any given text string (such as those above) include numbers, and
(2) what the first number (which could contain 1-4 digits) contained in the text string is?

View 3 Replies View Related

IF And FIND Statement For Multiple Text Strings

Nov 19, 2009

I have been given a huge membership list. The field for the CITY also as the two letter state abbreviation (e.g., "Fremont, CA" instead of just "Fremont".). I want to be able to have the "CA" or "WA" or "NV" (etc) from the city field appear in a new STATE field. I successfully use the below statement to do this with the "CA" but I want a statement that will search for multiple strings (the other states).
Here is what works now: =IF(FIND(" CA",F2),"CA"). But I want to be able to add other state abbreviations to this.

View 4 Replies View Related

Find Specific Account Value From A Range Of Text Strings

Jan 6, 2014

Need formula to find a specific account no. from a range of text and return that account's value as a usable numeric.

Account number:012345678 XZ
Account value as of 12/31/2013:$12,345,56

Account number:987654321
Account value as of 12/31/2013:$876,543.21

View 12 Replies View Related

Find Top 10 Most Common Words In Column Of Text Strings?

Apr 1, 2014

I've been racking my brains trying to find a way of doing this. I have a list (column A in Excel) of over 50,000 organisations and I'd like to know what the most common words used in the names are. Ideally it would great if I could produce a top 10 list of the most common words at the top e.g. Ltd, School or Church with a count in the next column of how times that word it appears

View 5 Replies View Related

Compare Text Strings In Two Columns And Return Text From Adjacent Cell

Feb 28, 2013

how to Chk the text string in particular cell, compare it with a super set column and get the full from of the text string from another corresponsing column and the output will be corresponsing full form of the chked text string?

View 6 Replies View Related

Lookup Part Text In Range In Cells Holding Text Strings

Sep 27, 2006

I try to write the function that gets some "ref" and returns appropriate item.
For example: if I give to function "C3", it returns "AAA"
if I give to function "R18", it returns "BBB" (cause it between R15 to R26)
if I give to function "R9", it returns "BBB" also.

View 9 Replies View Related

Extract Multiple Text Strings From A Long Text String

Sep 4, 2009

An original text string entry appearing in an Excel cell would be:

"N7C Neuroprotective J5Z Antiviral, other M2Z Antiarthritic, other J5A Antiviral, anti-HIV"

I need to extract N7C, J5Z, M2Z and J5A from this string and list these alphanumeric values in separate cells adjacent to the original text string. The challenge is that these alphanumeric references may appear in different positions within the original string with no fixed value e.g. a "," separating them. The alphanumeric references may also be 3 or 4 characters in length and there may be different numbers of alphanumeric references in the original string.

Another example would be (very different from the first):

"T2Z Recombinant, other K5B Radio-chemoprotective J3Z Antibacterial, other D3A Vulnerary A10C Symptomatic antidiabetic K6Z Anticancer, other R8A Antiasthma B6A Septic shock treatment I1Z Immunostimulant, other S1Z Ophthalmological R8B Antiallergic, non-asthma M1A1 Anti-inflammatory"

You can see that in this further example "A10C" & "M1A1" are 4 character alphanumeric strings wheras the others feature 3 characters.

View 9 Replies View Related

Looping, Open Text File, Copy Text, Close Text File

Sep 18, 2009

I have an existing spreadsheet with a column of strings (actually VIN numbers). These numbers correllate to a bunch of text files, that can exist in one of three folders (UsernameDesktop1, 2, or 3) on my desktop. What I need the macro to do is:

1) get the filename from A2 (A1 is a heading row)
2) Find the appropriate text file in one of the three folders
3) Put the folder name into I2
4) Scan the text file for some strings, and copy some data that follows those strings into J2:O2 (I can handle programming this)
5) Close the text file
6) repeat above for the remainder of filenames (about 1800 files)

View 3 Replies View Related

Extracting Strings Of Text From Columns Of Data(text)

Apr 23, 2007

What I have is a column of data(text) which contains amongst all the text three strings of text in ever cell in the column which I require copying into three adjoining cells

The data I require is :-

(a) The persons name which is always after the word ‘Requester’ e.g. Requester Steve Robinson

(b) Their office location which is directly after the persons name and is in brackets e.g. (Newcastle User)

(c) The Approving persons name which is preceded by ‘Approved by’ e.g. Approved by Christine Hunting

See examples 1 & 2 below

Example 1

CR0/CRZ3651 Requestor Steve Robinson (Newcastle User) Tel: 01234 798157 Approved by Christine Hunting

Please install and configure 2 Ultra 2s (typhoon and lancaster) for use as ARTE workstations. These workstations require Solaris 2.5.1 plus the same patches as before

Example 2

CR0/CRZ3118 Requestor Doug Cunningham (Newport User) Tel: 0114 9881480 Approved by John Smithers

Please provide support to set up Cisco 2691 Router and PIX-506E Firewall to enable external connection of a remote terminal for project work.

As you will appreciate the text in the cells is of non standard lenght and the three pieces of information can be located virtually any where in the text

View 9 Replies View Related

Text File Import With Text To Columns Splitting Same Text Differently

Nov 21, 2007

I have a macro which imports data from a mainframe dump text file and performs 'Text to Columns' on the imported data so that formula in the spreadsheet can act on the data. The code works perfectly well when I use it, but if a different user logs on and performs exactly the same mainframe dump and import macro the Text to Columns action splits the raw data in a different way and the result is that the split renders the formulae useless.

I've experimented a little and for some reason it appears that the 'Field Info' parameters which are produced when the Text to Columns function is recorded in a macro differ between users even though the raw data is exactly the same.

FieldInfo:= _
Array(Array(0, 1), Array(18, 1), Array(35, 1), Array(56, 1), Array(70, 1), Array(88, 1), _
Array(102, 1))

View 6 Replies View Related

Editing In Text Box

Sep 1, 2008

Is there a way to copy and paste my notes from Word into the text box once it is embedded in the excel worksheet?

View 9 Replies View Related

Find And Replace A String In Text File Using VBA?

Jan 17, 2012

I have a query in a text file.

Select * from
table1 where
a = %d
and b in ('%d','%d')

and values in excel:
value1
value2
value3

I want to open the file and replace the first %d with value1 and second %d with value2 and third %d with value3.

So finally my output should be:
Select * from
table1 where
a = value1
and b in ('value2','value3')

View 9 Replies View Related

Insert Text To One File - Remove Text From Equivalent Column In Another File?

Aug 13, 2013

Got a slight problem; I am making a "worker-plan", where you should be able to write a name on one file and have it updated (removed) from the equivalent columns on another file automatically. Here's an example with two separate projects:

Project 1 before and after changes:
Attachment 257366
Attachment 257367

Project 2 before and after changes:
Attachment 257368
Attachment 257369

You can see here how I intended it to work. When one worker is moved from Project 1 to Project 2, that worker should also be removed from those weeks in Project 1. The previous worker from Project 2 should also be removed from those weeks (in Project 2).

Are there any formulas that can make this work automatically? All week numbers will belong to the same columns in all files.

Edit: There are 30 files that should be syncronized, not just two.. I could also gather all files into one file with sheets, instead of having seperate files.

View 2 Replies View Related

Mass Editing Of Turning Text To Numbers

Apr 11, 2013

I'm trying to convert some data which excel is reading as text into numbers for example I have:

[Code] ......

All the numbers I've imported from an app analytics company into excel which are greater than 1.0 appear as numbers (to the right side of the cell) and all the numbers less than 1.0 appear as text (to the left side of the cell). I want all the numbers appearing as text to appear as numbers so I can multiply them with other cells.

I've clicked format cells - number but this has no effect. I click format cells -protection - unlocked but this has no effect.

I have thousands of rows with all numbers less than 1.0 as text instead of numbers. What's the easiest way to mass convert them all to numbers seeing as the above options haven't worked.

I don't want to have to click through thousands of rows to edit it manually...

View 5 Replies View Related

Extracting Hyperlink Text From Cell For Editing?

Jun 6, 2013

I have inherited multiple spreadsheets with thousands of hyperlinks in a single column, from all of which I need to extract the hyperlink text to audit it and edit it. The hyperlinks are only displaying less than useful words such as "Go To" "View" or "Click Here", for example.

Manually, I can right-click on the cell, select Edit Hyperlink, press Ctrl+End to select the entire link, press Ctrl+C to copy it, click on OK to close the editing dialogue, then paste it in the destination cell. That's easy, and good if you only have a few to do, but very tiresome if you have more than a dozen. Life's too short to do all those I need to do manually with a 29 day deadline!

I tried setting up a Macro to do it for me, but couldn't get it to work down a column and paste the result in the destination cell on the same row as each successive cell was located. I do very little Macro work, and I find Excel to be less than intuitive in this respect, so I gave up. (At least in Word you can see the whole step-by-step process in the Macro Editing window and easily fix it, if need be...).

One previous discussion, dating from 2006, supplied two answers. See [URL]

Should I set up a Macro and insert the above Function into it? Or is there a completely different way to do it? how to do this in Excel 2003/WinXP is very welcome.

View 5 Replies View Related

Editing Existing Text In Multiple Cells Macro

Aug 6, 2009

i have a list of about 20,000 phone numbers that I need to edit.

all start
01 123456
01 123457
01 123458 etc

I am trying to create a macro that will change them to

+001123456
+001123457
+001123458 Etc

However, no matter what I try it always comes out as

+001123456
+001123456
+001123456

F2 Copy and paste is going to take me forever, and I am sure that there must be a quicker way to do this.


this is my first time creating macros so am completly lost.
I want to keep the text that is in the cell that I am editing, just add the country code and delete the space.

View 9 Replies View Related

Excel Macro To Output Text File After Global Find And Replace

May 19, 2014

See attached image.

So what I am looking for is to put a macro behind button 1 which will do the following

Enter A Default Value Of 123 In The Yellow Boxes (B7:K7)
If They Are Blank When The User Clicks The Button
Performs A Search And Replace To Replace The Values 01-01-1990 With B8, 02-01-1990 With C8 Etc Until K8
Output The Contents Of Sheet 2 To A Text File (In XAI Format) In The Following Order A1:A100, B1:B100, C1:C100

[Code] .........

View 1 Replies View Related

Editing Formula Shows Text All Red, Parentheses Color-coded

Oct 20, 2007

But the formula seems to be working properly.

I've got ALOT of parentheses, 5 nested IFs, 5 ANDs, 4 ORs. The ANDs and ORs are within the IFs.

While editing the formula, I can, at times, achieve the condition where the cell references become color-coded. Or at least some of them do. But, when I get to this point, I'm usually at a spot where I can see the formula isn't right.

I'm confused. What does it mean when my text is all red when I go to edit a formula? Did I hit some limit? Again, I don't get error messages and the formula seems to work properly.

View 9 Replies View Related

Import Large Text File Across Multiple Sheets. Could Not Find Installable ISAM

Apr 19, 2008

I found following code on this site to extract txt files. As mentioned this code can extrack huge txt data to multiple sheets.

Sub ImportLargeFile()
' Imports text file into Excel workbook using ADO.
'If the number of records exceeds 65536 then it splits it over more than one sheet.
'If a file in a different format is to be imported amend the extension at line 10
Dim strFilePath As String, strFilename As String, vFullPath As Variant
Dim lngCounter As Long
Dim oConn As Object, oRS As Object, oFSObj As Object.............

However I am getting Run time error '-2147467259(80004005)': could not find installable ISAM for section 'Open an ADO connection to the folder specifiedin above code

View 2 Replies View Related

VBA Sum Different Strings Of Text

Dec 3, 2012

Different formula in different cells give me some text as output, to format this. I would like to copy and paste in one cell, so that I can easily then register a macro on top to wrap the text in one big cell.

View 1 Replies View Related

Manipulating Text Strings

Jan 12, 2010

I have a column filled with names per row. I wanted to standardize it by using the following format.

The comma after the last name is always an indicator to me that it is the last name.

<First Name> <Middle Initial(if any)> <Last Name>

My actual records contains the following:

BIMBO EPPING - OK
AHMAD SADICK - OK
Salana, Laura R - need to be arranged to > Laura R Salana
Cantos, Rhoda Grace J - need to be arranged to > Rhoda Grace J Cantos

View 13 Replies View Related

Check For Different Text Strings

Jan 9, 2012

Can the below be achieved with any formulae or macro -

I have 2 worksheets (sheet1 & sheet2). In sheet2, i have some colors in column A (e.g. "red" in A1, "blue" in A2, "green" in A3.

In sheet1, i have some text strings in column A, e.g.

A1: I love red color
A2: my pen in blue
A3: Green grass
A4: Orange juice
A5: I like red and blue

What i want in corresponding cells in column B, is the name of the color which is in column A. so my output should be

B1: red
B2: blue
B3: green
B4: "NIL" (any error message)
B5: red (even though it contains 2 color, i am happy to show any one of the colors it contains)

View 2 Replies View Related

References And Text Strings

Dec 9, 2012

n cell D3, enter a reference to the value in B7. Format the cell to display the text string Interest Rate.

In D3 i entered =B7 and the value for B7 popped up in cell D3, I am confused on how to enter the text string.

View 4 Replies View Related

Spliting Up Text Strings

Jan 16, 2014

What can split up text strings into two cells.

I have this in A1

"X,Y Coord Dn = ",38033.8,42701.7
I have this in A2
"Bearing = ",128.9

I want to split this text into 2 cells.

The Formula I am using for the B1 is:

=IFERROR(LEFT(A1,SEARCH(""",",A1)+1),"")
result = "X,
The Formula I am using for the C1 is:
=IF(A1=B1,"",RIGHT(A1,(LEN(A1)-SEARCH(""",",A1)-1)))
result=38033.8,42701.7
The Formula I am using for the B2 is:
=IFERROR(LEFT(A1,SEARCH(""",",A2)+2),"")
result="Bearing = ",

The formula I am using for the C2 is:

=IF(A1=B1,"",RIGHT(A1,(LEN(A1)-SEARCH(""",",A1)-1))) result=128.9

I am using the same formula down each column; But i can not seem to ge the "X,Y Coord Dn = ", to work properly.

View 9 Replies View Related

VB For Finding Certain Val's At END Of Text Strings

Nov 15, 2006

Column A has prepopulated list of values of various lengths, no spaces. Need to search column A for certain values at the END of each text string, and then populate the cell right next to it with another constant value.

Example: macro searches column A for cells with "123" at the END of the cell value (whole cell value could be A123 or ABC123, etc...). When macro finds the cells that meet this criteria, it places the constant value "XYZ" in column B right next to the cell in col A.

I need several variations on this theme and the # of characters being searched for at the end of each text string can vary. The constant value to be inserted in Col B can also vary. I imagine 'For Each' loops for every variation would work, I just do not know how to write the code for searching the "end of the text string" part of it

View 9 Replies View Related

Countif With Text Strings

Oct 23, 2007

How would I write a formula to Countif or Sumif a cell contains a string of text? ie if I wanted to look for "Andrew" in cells that contained the text "AndrewKent", "Andrew Kent", "Kent Andrew" etc how would I do it?

View 9 Replies View Related

Joining Text Strings

Jul 28, 2006

I have to cell values that are strings and I want to add the two string values together to form a sentance, when I do this using a + sign or a & sign there is no space between the 2 strings, how do I get a space?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved