Compare Two Strings And Find Difference?
Aug 6, 2010What I'm trying to do
A1 = Hello John, my name is Steve, how was your day?
B1 = Hello John, my name is Steve, was day?
I need C1 to return:
how your
Is this possible?
What I'm trying to do
A1 = Hello John, my name is Steve, how was your day?
B1 = Hello John, my name is Steve, was day?
I need C1 to return:
how your
Is this possible?
I have two lists (List A and List B) of hundreds of items that reside in a single worksheet.
Some items may or may not occur in both lists.
Every item in both lists has a value on the range of 1-50.
I am only interested in those items that occur in both lists.
I need to find the difference of the values for each of these items (List A - List B), including negative values.
I have tried many variations of formulas using VLOOKUP with no luck.
I cannot figure out how to accomplish this with a Pivot Table.
I want to make a macro for this.
Here's an example:
List A
W 29
X 11
Y 13
Z 4
List B
V 8
W 10
Y 30
Z 6
Where the results would be:
W = 19
Y = -17
Z = -2
I am using the function "Exact" to compare 2 strings but I would like to highlight the difference if possible.
I have a workbook called Keyword that has two columns c,and d, of words.
The length of the columns can vary,because I add words to them.
I also have a workbook called testfile, and cell B1 has a word in it.
Testfile also has an .xla module that adds in when testfile is open.
I want to type a function called asset in cell C1 of Testfile,and have
it compare each word in Keyword workbook to the word that's in cell B1
of testfile. If a match is found in column C of Keyword, the function
returns the letter C. If match is found in col D of Keyword, it returns
the letter D. If no match, function returns "no match".
I have both workbooks open and the vba code I stuck at the bottom of
the .xla module as another function.
Here's my code so far.
Function asset(Description As Variant) As String 'arg. is the word in cell B1 in testfile
Dim LastRowOfC As Integer, LastRowOfD As Integer
Dim i As Integer
how can I get the red highlighting to work like so?
Test Test_002 6698F ES6698F DVP3142 DVP3144 GTM8800 GTI8000 SDV394 SV384STC
I have two numbers, they are version numbers, I am having problems with my If then else and elseif statements.
59821 for version 5.9.8.2.1
is more than
5983 for version 5.9.8.3
even though 5.9.8.3 is a greater version number. Do you see where my problem is. How do I compare # by # reading it, checking to see what one is bigger and going from there. so when it gets to the 3 of the 5983 its bigger than 2 of 5982 of the 5.9.8.2.1
I'm writing quite a large electronic logging program using excel and vba and have hit a snag in one of my subs which reads from a text init file. Let's take a look at the code.
Private Sub ReadInit()
'Opens txt init file, looks for target list, splits line by commas and enters into array
Dim FileNumber As Integer
Dim TargetsRead As Boolean, LastFileRead As Boolean
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = ObjFSO.OpenTextFile(SaveDir & Init)
TargetsRead = False
LastFileRead = False
Do Until objFile.AtEndOfStream 'do until end of file
I am having no success using either: 1) COUNTIF with wildcard (*) or 2) Case Statements to find text strings in a cell. I've even tried using Copy/Paste Special values to change the way Excel 2007 interprets the field.
The Do While loop looks at target cells in Col. 18 which contains one or more specific last names. I want to put a text string (also a name) in Col. 19 IF the target cell contains the last name in the COUNTIF or Case Statements. The COUNTIF normally puts a TRUE or FALSE based on the condition, but I'd like to put the the last name based on which condition is met and then continue looping to Row 3. It's a small number of rows, less than 100.
Here's the Case statement ...
I have 2 sheets that either contain the exactly or close to same data. I have Sheet1 and Sheet2, and I want to highlight ALL cells in Sheet2 that are not the same as the ones in Sheet1. That is, I need to give a cell in Sheet2 a different background color (to highlight) if:
the cell in Sheet2 has a different value than the cell of the same location in Sheet1
the cell in Sheet2 is blank but the cell of the same location in Sheet1 has something in it
the cell in Sheet2 has something but the cell of the same location in Sheet1 has none.
All highlighting needs to be done in Sheet2. The problem with the codes that are already available in this forum seem to have problems when the ranges of cells used in the two sheets are different (out of bounds, etc...)
I am trying to create my own budgeting tool. I have most of the tracker set up but I hit a stumbling block. I downloaded transations from Bank of America as a CSV file into excel. I want to categorize these transactions.
I created a keyword list that has words like "Starbucks" "Exxon" etc. Each of these keywords is then listed next to a category like "food" and "gas". So I want a formula that will compare the transactions to my keyword list and return the category type. Here is an example transaction:
CHECKCARD 0256 STARBUCKS USA 00029801 GAINESVILLE VA
I have a keyword "Starbucks" in f2 and "food" in g2.
Suppose we have 2 cells
Cell 1
Cell 2
O/P needed
abc123
abd123
d123
xyz112
xyz113
3
abc911
axz111
xz111
abc119
abc130
30
abc121
abc122
2
The formula would basically need to check each character sequentially in both cells[starting from the left most character] till there is a mismatch and then display the characters that follow in the second cell (including the character with a mismatch) in the output cell.
it basically looks like this:
ABC1234
ABD1239
I want to get D1239 as the result after using a formula.
Is there a way this logic could be extended to 12 characters?
I have two columns of values and I want to compare them and return differing values. So I named the ranges "A" and "B" so if your in B but not in A I want that value in C.
I started with a vlookup but that doesn't seem appropriate to the way I was using it.
=VLOOKUP(B, A, A, FALSE)
Is there a function better for this.
I'm looking at trying to view 1 large keyword phrase list of about 40,000 phrases to another large list.
All I want is a macro, I can assign a button to. Click it and in a new sheet it shows only the rows of data that are different.
I have tried googling it.
I found 1 that looked very good (Not that I really know anything about coding, but I couldnt get it to work.
I'm using excel 2007.
As a note the link was here.
[url]
I might as well post the code,, but I just couldn't get it to work, shame, because it sounds like it could be what I was after, I'll post it now, but if anyone can help me with this that would be great
Sub CompareWorksheetRanges(rng1 As Range, rng2 As Range)
Dim r As Long, c As Integer
Dim lr1 As Long, lr2 As Long, lc1 As Integer, lc2 As Integer
Dim maxR As Long, maxC As Integer, cf1 As String, cf2 As String
Dim rptWB As Workbook, DiffCount As Long
If rng1 Is Nothing Or rng2 Is Nothing Then Exit Sub
If rng1.Areas.Count > 1 Or rng2.Areas.Count > 1 Then
MsgBox "Can't compare multiple selections!", _
vbExclamation, "Compare Worksheet Ranges"
Exit Sub
I have a string compare function that compares two strings and return 1 if matches. Each string has multiple words separated by ",", and all these words need to be matched.
This function is done, but I want to add a little feature to it. For each string, if one word cannot be found in the second string, change that word's size to 14, fontstyle to bold.
Function StringCompare(value1 As String, value2 As String) As Integer
''this function compare the words from 2 strings
''each word is seperated by "," and the order of these words does not matter
''return 1 if matches, 0 if not match
Dim v As Variant, u As Variant
Dim i As Integer
Dim answer As Integer, answer1 As Integer, answer2 As Integer
answer1 = 1
answer2 = 1
I need to look colB and colC should be equal to colH and colI, IF both cells matched, then copy the EmpNo(ColB or colH) and Counter(colC or colI) get the difference of values in another colomn
If there is any row for Employee or Counter issing from either of tables populate with RED in either of 2 colomns,
for example:at row 17, table 1 has a missing colC, and row 17(table1) = row18(table2), it should populate the row17 for table2, as a reference.
I am trying to compare two lists and extract from one to add back to the source. However neither are alphabetically.
List 1
accessories
belt
boots
cardigan
coat
glasses
gloves
hat
List 2
tshirt
tshirt
jumper
jumper
jumper
tshirt
shoes
cardigan
So i would the vlookup to add automatically back to list 1 tshirt, jumper and shoes.
List 1 would now look like this
accessories
belt
boots
cardigan
coat
glasses
gloves
hat
tshirt
jumper
shoes
I have 1 workbook contains 2 Sheet with Name and Address in Column A,B,C,D. Sheet1 always contains New Data of Name and Address and its import from another software.
I need a macro to Compare these 2 sheets, Highlight the rows which is not in sheet2
I have the following code, which works great, but I need the cells to highlight only when the difference is more or less than 5%
how can I adjust for this?
Code:
Sub RunCompare()Dim sheet1 As String
Dim sheet2 As String
sheet1 = InputBox("What is the First Sheet Name?")
sheet2 = InputBox("What is the Second Sheet Name?")
Call compareSheets(sheet1, sheet2)
[code].....
I have 2 ranges named MASTER and SUBSET and 1 range named ANSWER. I want to compare ranges MASTER and SUBSET and copy the difference to ANSWER. The ranges have the same number of columns but different number of rows. Sample data is below.
Ideally, I would like a VBA solution executed from a userform button.
Example:
MASTER
aaa apple
aab banana
aac grape
SUBSET
aab banana
ANSWER
aaa apple
aac grape
I would like to compare % difference between date range through pivot table
Date RangeProductAmt
1st weekABC1000
2nd WeekABC2000
3rd WeekABC1259
1st weekXYZ3000
2nd WeekXYZ4000
3rd WeekXYZ2500
How to plot a Pivot table to compare the % difference between 3rd Week Vs 2nd Week Vs 1 Week for each product through pivot table?
Sheet1 is Main Sheet which never will be amended and these numbers will be a source for pulling mathematical functions
See attached :
Sheet1.png
Don't be bothered about cell colors etc. They are for my reference
Sheet2
Will contain same Problem Ticket numbers but different (or same) values with number of 'Linked Incidents'
See screenshot
Sheet2.png
Based on Problem ID 10248
Main sheet shows 92 Linked Incidents
Value on Sheet two brings 93
If A5 Sheet2 value can be found in ColumnA Sheet1, look for a number in ColumnC, same ROW and compare it to C7 in Sheet2 ?
Bring up difference value, which in this case would be one.
I'm just trying to view the results of this search, I don't need it to make changes to the cells on the bases of this search.
I'm using control + F to open the search box.
It only allows me to type in one single string, such as "Johnson". Problem is, it finds many rows that contain the name Johnson.
So I'd like to further add a number, such as 1.3338, which it can look for in any cell that's on the same ROW where it found Johnson.
It would then return, for example, Row number 81, which has a cell that contains Johnson and another cell that contains 1.3338.
I have a set of 4 columns with YES/NO statements in them.
I need to find any YES strings, of three or more, within one column, uninterupted by a YES in another colum.
EXAMPLE:
_____A ___B__C__D__E
1 1/1/2008 YES NO NO NO
2 1/2/2008 NO NO YES YES
3 1/3/2008 YES NO NO NO
4 1/4/2008 YES NO NO NO
5 1/5/2008 NO NO NO NO
6 1/6/2008 YES NO NO NO..................
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 RelatedI 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?
For Eg: i have 1000 students...i entered marks to all the students now i
need to fine the total students who have score >50 and <60 in each subject..
I am currently trying to write a macro that will search a column for different strings. These strings are inside the cell (as in it is not the only value in the cell) and then copy the entire cell over to another column, then delete the two cells to the right of the originally found cell.
Heres an example of what I want to:
There are four columns, the first has a name with both the first and last (amanda white)the second just the first name (amanda), the third just the last name(white), and the forth an organization name. if the first column contains an organzation name, it has to clear out the first name and last name columns, and copy the name column to the organization column.
NAME | FIRST | LAST| ORG|
amanda white amanda white
mike jones mike Jones
pizza hut pizza hut
I have a list of organization keywords to search the first column (e.g. enterprise, variety, management, pizza). I want it to recongnise the "pizza", copy that entire cell over to the organization column and delete the first name and last name for that row.I've been trying to modify a code like this but i can't seem to make anything work.
VB:
FindWhat = "pizza"
For Each Cell In Range("B2", Range("B" & Rows.Count).End(xlUp)) [code]....
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.
I need to loop through a worksheet to find the following product ID's: 100805, 6950000, 853000 and 20994000. Each time I find the product ID I have to execute the same code in that part of the worksheet to extract data.
I just do not know how to set up the macro to loop through each ID.
I am having a hard time creating a code that would search the exact string in a cell. See sample scenario below.
1. I have a string "hello" to be searched.
2. I will search the whole string in each cell in a previously declared range.
3. If in a cell i found "kdhlsk hellodsiewjls", although "hello" string is there,
the code should still return 0.
4. But if in a cell, i found "kjdsfel ljsdlkue hello luoeww", then the code should return 1.
I have already created a code, but it will always return 1 in step#3.