Compare Range To String?
Jan 24, 2014
I am working on a project where I need to remove records based on certain criteria.
The key pieces of information here are the Company ID, the Contact ID, and the Product Codes. Each Company ID can have multiple Contact IDs, and each Contact ID and have multiple Product Codes. (To be more clear, imagine one company with a Tax department and an Audit department - with each department having a separate contact person. And, each contact person purchasing multiple products.)
I have already summarized the data by identifying the unique Contact IDs and combining the corresponding Product Codes into a string.
Now, I need to determine if any Product Code within the summarized string matches a Product Code in a separate list (a Range of cells). If so, each instance of the Company ID needs to be moved into a different tab. Also, to understand the magnitude of my records, I am working with 25,000+ unique records in the first tab, 8,000+ summarized records in the second tab, and 50+ product codes in the separate range in the third tab.
My first thought was to use a For loop to determine if any cell in the Range is found in each string and, if so, add the related Company ID to a dictionary object. Then, run another For loop against the Company IDs in the summarized tab (8,000+ records) to determine if the ID exists in the dictionary and, if so, moving the row to another tab.
My second thought was using the original data (unique records) - I would load all the Product Codes in the separate Range into one dictionary and run that dictionary against the individual Product Codes in the unique records tab (25,000+ records). If the Product Code in the unique records is found in the dictionary, I would add the related Company ID to another dictionary. Then, I would run a For loop comparing the second dictionary to the Contacts IDs in the summarized tab and move the ones that exist.
In summary, the two ways I have come up with to accomplish what I need includes:
1) a For loop, a dictionary, and another For loop
2) two dictionaries and a For loop
View 6 Replies
ADVERTISEMENT
Aug 23, 2007
I have a problems here. The problems is attached in the file. I wanna extract alpha/char from a string. Example: I wanna extract the words "(M)" with the bracket from the string "Toothbrush (M)" in column A. After extracting the (M) out, I wanna do a validation to compare the (M) in column B with another data in column C, if the (M) is same as the data called "Medium" in column c, the validation will return "Match" in the column d!
View 9 Replies
View Related
Aug 4, 2014
I want to compare a string in a different workbook. and find the relevant cell value of that.
e.x. in one worksheet the value displayed like "DEBIT/ATM CARD TRANSACTION FEE" But in another worksheet the value displayed as "018 - Debit/Atm Card Transaction Fee".
Now I want to compare this string and the value displayed in the column E for this row of workbook 2 should be displayed in workbook 1 in the column D.
View 6 Replies
View Related
Mar 27, 2014
I am trying to to work out how to compare two string variables that I can see with my eyes are clearly a match but getting the right syntax to convince VBA they are the same is my issue.The first example is:
Direct Credit 158824 BRANDON DONNA C/ Lak30
the second example is:
Direct Credit 158824 BRANDON DONNA C/ 30 Lake Vue Parade
but that still would not get a match that I can find code for.
i am chasing the "holy grail" in VBA and I will leave the records that do not exactly match to manual processing although i hate to give up that easily
View 2 Replies
View Related
Apr 18, 2013
Some data
In Cell A1 This is a bag
In Cell B1 This is a bag with books
now in Cell C1 i need the mismatch words With books
C1 should show with books
I am now manually finding the words of cell A1 in Cell B1 and then writing the mismatched words C1 .
View 3 Replies
View Related
May 28, 2009
I was trying to compare string from excel spread sheet to a value I am not getting any output. It is not working
View 4 Replies
View Related
Mar 28, 2014
What I am trying to do isn't very complicated. I started on some code, but it's just not good enough to do all of what needs to happen.
A
B
C
1
Cupcake Monster
Aisle 5
Shelf H
2
The Cupcake Ghoul
Aisle 2
Shelf P
3
Fred Baxter's Diary
Aisle 1
Shelf X
4
Angry Cupcake Beast
Aisle 3
Shelf A
5
Everyone Loves Cake
Aisle 4
Shelf R
So I have a list of titles that I want to search for a particular string. The title in this list is the "proper" title,whereas the rest of my workbook typically uses a shortened version of the title. Sometimes the two will match 100%, but usually, they will be close.
If the string in the table above has more than 2 words, I want to use the first 2 words to check for a match. If the string has 2 words (will never have fewer), I want to match the first word. I want to do this IF there is no 100% match (if possible or reasonable). I will settle for just matching 1 or 2 words. I want to copy the values to another sheet and then delete the row that I originally got the data from.
What I want to do is search the list for "Angry Cupcake" and return the Aisle and Shelf location of Angry Cupcake Beast. There will never be any other "Angry Cupcake", so I am not worried about mismatches there.
Code:
Dim SearchRow As Integer
Dim StoryTitle As String[code]....
how to do and can get to work without issues is an exact match. This still leaves out all of the shortened titles though.
View 3 Replies
View Related
Aug 25, 2008
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
View 9 Replies
View Related
Dec 19, 2013
Basically I have a string of dates, I want to get the max of the values that are before a specific date and return the header. Look at the file I provide for better understanding.
View 2 Replies
View Related
Jan 31, 2008
I need to compare a list of keywords (stored in a string variable) with the content of a cell in order to see if any of the keywords do appear in the cell. I have to work with many such lists which can grow over time. What I'm doing is using InStr(cell with content, keyword) for each keyword. My goal is to have a macro which can automatically create the long formula from any list. My actual problem is that the formula I've build and stored acts more like a string. I'd like it to say either true or false. Anyway, here's a sample of what I came up with so far.
Sub build_formula()
Dim i As Integer, j As Integer, m(20) As Integer, n As Integer, z As Integer
Dim List As String, f(2) As String, s(20) As String, sp As String, Source As String
Dim Formula As Variant
List = "black, blue, green, red, yellow, white, z"
Source = Cells(3, 1).Value
z = InStr(1, List, "z")
i = 1
n = 1
Do
i = InStr(i + 1, List, ",")
m(n) = i ..........................
View 5 Replies
View Related
Oct 22, 2012
I need to compare a string from say A1 to a range of cells in another workbook and if found return the value of a cell on the same row.
Something like - look up string value in A1 in other workbook.sheet1.A1:A65535 if matched return the value of matched row column b.
OR
IF Otherworkbook.sheet1.A20 = A1 return the value of B20
View 6 Replies
View Related
Jan 7, 2009
I have another problem with this damn address file. Column H and I have data in them that is often mixed. As shown below, I have used A and B below, but its normaly in Column H and I. I would be greatul if some could write a macro to split the data into the two columns.
Rows 2-8 is what Im presented with. I would like them to look like 11-17
Note that the number in row 8 does not match, so is left for manual intervention....
View 9 Replies
View Related
Oct 11, 2006
I was looking to use the VBA conditional formatting script posted on OzGrid and was curious if it would be easy to make some slight modifications.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Select Case Target
Case 1 To 5
icolor = 6
Case 6 To 10
icolor = 12
Case 11 To 15
icolor = 7
Case 16 To 20 ..........................
I can see that Case is the number range referenced to change the background...However, would it be possible to have it read a cells value as the criteria for the color change? Currently, I would like it to reference values in range I2:M2 and anything matching those cells in range A4:E28 change background to icolor = 30. I'm just not sure what to replace Case with to make it refence cells I2:M2
View 6 Replies
View Related
May 12, 2012
I have a dataset of shifts and want to compare each shift that needs to be filled to a list of requests for time off (vacation, etc).
For one cell the code is: =IF(ISERROR(SEARCH(B1, A1), 0,1)
Where A1 is the column of requests in comma delimited forme (ie: "AB,CD,EF").
Where B1 is the column containing the person assigned to shift 1 (ie: "AB")
In this case, would return a "1" as no error was returned, as AB was found in the list. Here "1" would represent a schedule conflict.
Without creating many cells for each shift- there are 20 shifts- can I create an array or string together this type of "SEARCH" function?
View 1 Replies
View Related
Dec 12, 2008
I am trying to compare one range to another. If an item in one list is not in another i am adding this item to an array called addarray. The problem is when i try to access the array to see if one of its entries is "" i get a type mismatch error. My code is shown below:
View 5 Replies
View Related
Feb 17, 2014
I am trying to create report of the in and outs of tools we are shipping for repair.
Currently in Tab 1
Column F - Date shipped for repair
Column G- Vendor Name
Column H- Date Returned
What I need in Tab B
Vandor - Total Sent- In Repair @ Vendor- Total Repaired - Total Unrepaired
Here are Images if it makes it a little easier to understand
The Info I currently have
image1.png
The info I required filled out based on the previous data
image2.png
View 6 Replies
View Related
Aug 3, 2009
Using VBA, I want to import data from a text file into a worksheet, but only import a row of text if the three-letter code matches one I have in a named range. The data looks similar to this:
ALF,D,06/01/2009,0.96,0.97,0.96,0.97,1007,0
ALK,D,06/01/2009,0.34,0.36,0.34,0.345,4375,0
ALL,D,06/01/2009,3.7,3.8,3.68,3.75,12381,0
ALR,D,06/01/2009,1.155,1.18,1.155,1.17,388,0
ALS,D,06/01/2009,3.39,3.39,3.23,3.31,2642,0
ALT,D,06/01/2009,0.031,0.031,0.031,0.031,3460,0
ALY,D,06/01/2009,0.1,0.105,0.1,0.105,460,0
etc...
and the named range similar to this:
AAC
AAF
AAM
AAR
AAX
ABB
ABC
ABP
ABQ
etc....
I know how to open and import the data, it's just making the comparisons that I'm having trouble with at the moment .
View 4 Replies
View Related
Sep 22, 2008
i'm trying to do some analyzing on an excel sheet and was seeing if there was a function that I could use to speed this up.
So in the file...
I want to Group what's in Column A So the 1's together and the 2's together... Once that is selected I want to know what the largest number in Column C is...
So if the function can select 1 in column A then tell me that 10 is the biggest number in Column C....
View 14 Replies
View Related
Apr 2, 2012
Here is what I want to do:
If AND(NOT(ISBLANK(A1);A10) then B1= "NOT OK"
else
If AND(NOT(ISBLANK(A1);A1=0) then B1="OK"
End if
How to do this for a range A1:A10 in vba??
View 5 Replies
View Related
Oct 22, 2013
I have a question on the vba syntax. I have a column of data whose values decrease by 1 or so as I move down the cells. My data look like:
A B C D
999.1 111
1000 110
1001 109
And here is a code that I have written:
Code:
Sub ppm_sort()
Dim strrow, endrow, i, j As Integer
strrow = 1
endrow = 5000
For i = strrow To endrow
[Code]...
What this code does it, it first looks at Column B and pulls the values from Column A to C until the value in B hits 1. Then it calculates the average of the pulled values, after which it deletes the values in column A to C. If values in column B are greater less than 100, it does not calculate the average and just deletes the columns, moving the cells up. However, I ran into this problem:
A B C D
999.1 80
1000 110
1001 109
I still need to pull the values and calculate the average but since the value in B1 is less than 100, the code does not do so. So I tried to change the code colored red above to:
Code:
If (Range("B1:" & "B" & i).Value < 100) Then but excel gave me an error of 13 run time error. Basically, I need to figure out how to compare the values in a range to a number and combine if statement.
View 1 Replies
View Related
Dec 5, 2007
i have a range of values and want to compare the value of a single cell to all those in the range, returning TRUE if a the value matches any value in the range.
View 5 Replies
View Related
Feb 28, 2012
I am looking to compare a range that contains the non blank cells and identify if the values are the same in the last 3 non blank cells in that range.
(in the range there could be as much as 12 non blank - but only compare the last 3)
View 1 Replies
View Related
Jan 30, 2014
I need making a macro which compares a particular range of columns in one sheet to other sheet in same workbook.
It is like i have two worksheets named "Working Copy" and "Cleaned Data - (Working)". In this I have to compare Columns (A:AG) from Working Copy to columns (B:BH) of Cleaned Data - (Working). and if there is any difference between any cell then it should be highlighted with a colour in both the worksheets.
View 9 Replies
View Related
Sep 6, 2006
I have a list of dates in Column A, prices in Column B in Excel. I would like to write a VBA code that compares Price #31 in the list to the previous 30 prices to see if the price has moved more than 8%. If the price has moved more than 8%, I would like the date(s) that it moved above the 8% level written in Column C. Then, I'd like the routine to move on to Price #32 and have it look at its previous 30 prices and do the same.
View 9 Replies
View Related
Sep 13, 2006
i have 2 workbooks attached, in the "work order masterlist 2006.xls" workbook, i'm trying to compare column F which is the R date to see if it matches the dates in the "2006 Calendar.xls". if it's the same date, i would like to copy from "work order masterlist 2006.xls", column C, which is the Client's name to "2006 Calendar.xls" under its appropriate date, assuming that:Dates of the months will not change column/row in the "2006 Calendar.xls"it will be an added bonus if i can copy and paste the description as a comment...
View 3 Replies
View Related
Jan 7, 2008
I am trying to get rid of some duff data by running a comparison to a fixed value on a defined range. However, the macro tries to compare the cell value (00:05:00) as a decimal value.
I think I need to use the format function to get round this.
For Each timecheckcell In range("g3:g60")
timecheckcell.Value = Format(MyTime, "h:m:s")
If timecheckcell.Value <> "00:05:00" Then timecheckcell.Offset(0, 1) = ""
Next
View 9 Replies
View Related
Jan 12, 2008
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 ...
View 9 Replies
View Related
Jun 3, 2014
I am trying to find out how many weeks our current inventory will support our sales. I am trying to research formulas that will do this, and coming back with things like OFFSET, MATCH, INDEX but am not certain the best way to put them together to get what I need. I use excel daily, but this is a bit mroe advanced than I am used to
Mini.xlsx
Starting in cell B4, I would like to count how many weeks of Demand can be covered by the specific Available On Hands in row 3 for that week, put the number of "Weeks Covered" into cell B2, and then fill over to the right in row 2. Right now, the values in row 2 are from my own manual calculations, but I would like a dynamic formula that will sum up the values in row 4 up to (but not greater than) the value in B3, give the count of cells that reached that sum (or even better with decimals to show the percentage covered), which I will copy over into B3:B13. Not sure if that makes sense, or if I can explain in a better way. The yellow cells are what I am trying to create a formula for and am currently stuck.
View 6 Replies
View Related
Jan 25, 2014
I'm doing a study of wind turbines, which are spread over a test field. There are 6 turbines, each checked once a day and produces a value. I look up what the weather man says it should be, "Reported" field.
Compare141622263647
DayWind1Wind2Wind3Wind4Wind5Wind6Reported
2872 6918243519
2867122327303133
2854111324324619
28422232527284624
28319233136454627
282411182841448
2819121622264814
28016242530344549
The "Compare" field values must match all values for each turbine. The speeds identify the location with the best match speed against output of power generated. As each value in "Compared" is the best speed for that type of turbine.
View 4 Replies
View Related
Feb 21, 2014
I am trying to compare vertical range "A" in sheet1 to vertical range "K" in sheet2 if they match to copy both rows and place in sheet3. I have tried the following but it did not work.
Sub Searching()
Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
' create short references to sheets
' inside the Sheets() use either the tab number or name
Set sh1 = Sheets("Sheet1"): Set sh2 = Sheets(2): Set sh3 = Sheets(3)
[Code] ......
View 1 Replies
View Related