Find Function Where Search Criteria Isn't Exact Match For Cell Contents
Dec 19, 2011
I am new to VBA and am having difficulties in getting a find function to successfully locate search criteria within cell. When the search criteria matches exactly that of the cell contents then the code works; however should the search criteria only form part of the total cell contents (such as a seach for "the" in a cell containing "the cat sat on the mat") the code doesn't recognise it.
Essentially, I need the code to search a range for the required string and if found within a cell activate that cell and populate a combobox with the full cell contents of the activecell.offset(0,-2).
The relevant section of code attached below:
Dim role_count as range
Dim role as string
If Application.WorksheetFunction.CountIf(Range("Role_Count"), Role) 0 Then
Range("role_count").Select
Selection.Find(What:=Role, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Me.Controls(ComboBoxName) = ActiveCell.Offset(0, -2).Value
View 4 Replies
ADVERTISEMENT
Jul 17, 2006
I need to search for an exact match within a cell & i am unsure of how to go abt it. Eg ) Cell A1 contains "Emea West,Emea East,Emea". I want to search for the term "Emea" in the contents of the Cell A1. I cant use Find() as using "=FIND("Emea",A6)" returns 1 ... But i want an exact match i.e "Emea" only which in this case should be 21. The Exact() works well if Cell A1 had a single value ...I guess I would need to use some array function here which will parse through contents of the cell , but am not sure on how to go about
View 5 Replies
View Related
Feb 18, 2012
I'm trying to find an exact match to a cell and not xlPart of it, but not sure what the syntax is, (Always where can I find a list of the properties?
Code:
Set Ran2 = Worksheets("TicketsList").Range("B8:IV200").Find(Count, lookat:=xlPart)
If Not Ran2 Is Nothing Then
CallRow = Ran.Row
CallCol = Ran.Column
End If
MsgBox "Row is " & CallRow & "Column " & CallCol
View 1 Replies
View Related
Nov 2, 2009
I have a workbook with many many sheets in it. The first sheet contains a single column with about 10,000 different values. I'd like to use each of these as search criteria against ALL data in the other sheets (of which there are a good 50 or so). If matches are found (they don't have to be exact case), then I'd like two things to happen:
1. The rows containing the matched search criteria in the first sheet are highlighted.
2. In the cells adjacent to the search criteria in the first sheet, hyperlinks to the matched data are created and named after the sheet upon which this matched data appears.
I've attached a sample file to this post with ideal sample 'answers' to queries made of the first 2 terms.
View 3 Replies
View Related
Mar 13, 2014
This is the script I have now:
[Code] ......
It works, unless there is a column before the "Categories" column that has the word "Categories" somewhere in its text. So basically if there is a column that has "Unit Categories" it finds that column when I really want it to find a column that has exactly "Categories" as the text and nothing else (but I don't want it to be case sensitive).
How do I force an exact match using this script?
View 1 Replies
View Related
Jan 6, 2014
Let us say I have the following text in Cell A1. "There is a fault in the cal cycle.Need to update the records." And in cell A2 I have the following text. "Called for backup assistance. There is an issue with numbers." I cells B1 & B2 I need a particular formula which searches for the substring "cal" exactly and returns true if present. In cell A1, we have "cal" in the text. So it should return true for me in cell B1.
However in cell B2 I need false to be returned even though I have "Called" inside the text. I need true to be shown only for those cells where we have the exact text "cal" and no text characters in front or back of it.
View 3 Replies
View Related
Oct 3, 2013
I am having a row with values from 21 to 45 and continued again from 1 to 25
Some unknown number of rows in the beginning
25
26
...
40
41
42
43
44
45
1
2
3
4
.
.
24
25
to find column position of "1" i am using code
Worksheets("sheet1").Rows(2).Find(What:="1", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).Column
But it is returning column number of 31 and when i delete or hide that column it returns column number of 41.
Cant i search for exact value 1 in my row?
View 9 Replies
View Related
Apr 4, 2014
I'm trying to use the MATCH function. I want to locate an exact name. I used the formula:
=MATCH(A6,A3:A10,0). This is the name cell I want to retrieve, the column in which the information is found, and 0 for the exact match. The return answer I get is 4.
View 3 Replies
View Related
May 30, 2012
This section of code I am working on requires me to find an exact text (I tried lookat:=xlWhole, but I can't get it to work right). The problem being is when it searches for Q1, Q10 is an acceptable answer ans so on. I need to get the 4th occurrence, but my research into Nth occurrence stuff is confusing.
The search is in a single column.
With Workbooks("FY12-Q3 Data Tables.xlsx").Sheets("PBA Crosstabs").Columns(1)
Set c = .Find(rCell, LookIn:=xlValues, lookat:=xlWhole)
Set c = .Find(rCell, After:=c, lookat:=xlWhole)
Set c = .Find(rCell, After:=c, lookat:=xlWhole)
Set c = .Find(rCell, After:=c, lookat:=xlWhole)
End With
View 9 Replies
View Related
May 10, 2014
How do i find an exact match in a range (Text exactly the same just like the exact function)
=MATCH(A1,B1:B10,0) This will match the rad and Rad to be the same but what i want is the exact match
I know the exact function does not take an range so how can i amend to take this to account?
Something like =Exact(A1,B1:B10)
View 1 Replies
View Related
Apr 27, 2009
I am having a slight VBA issue I need a little help with. I have created a catalog of books in Column A. As each new letter is reached there is a new heading. For example:
Cell A1 : A
Cell A2 : Book beginning with A #1
Cell A2 : Book beginning with A #2
Cell A3 : Book beginning with A #3
Cell A4: B
Cell A5 : Book beginning with B #1
Cell A6 : Book beginning with B #2
Cell A7 : Book beginning with B #3
Cell A8 : C
etc.
What I am looking to do is create a macro for each letter so that if I went to the "B" macro it would make the active cell A4. However the list of books will grow as my library does, so the macros have to find the letter rather than go to a predefined cell.
The code I have so far is (this example is for the letter B):
Sub B()
Columns("A:A").Select
Selection.Find(What:="B", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False).Activate
ActiveCell.Select
End Sub
However this code finds the first time the letter B is used in a word, not the cell that only has the letter B in it. Also I need to make sure that if the active cell when the macro is run is below the letter that it needs to find that it will still find it. I'm not sure if my current code would do that or not.
View 9 Replies
View Related
Oct 9, 2006
I'm using the below VBA
Dim c, DataRow
With Data
Set c = . Range("A5:A350"). Find(KPI, LookIn:=xlValues)
If Not c Is Nothing Then
DataRow = c.Row
End If
End With
Now,If KPI is for example = "Favourite Hotel" and if i have data that looks like :
Favourite Hotel - London
Favourite Hotel - Cardiff
Favourite Hotel
Favourite Hotel - Birmingham
Then it seems to not look be looking for an exact match (e.g. Favourite Hotel) and rather is finding the first item in the list that contains the KPI string (E.g. Favourite Hotel - London).
How do i make it search for an exact match?
View 4 Replies
View Related
Jun 21, 2012
How can I modify the following formula to find the contents of reference cell, for example if the cell reference (G$3) is equal to 9 I want it to use 8 instead.
Code:
IF(ISERROR(INDEX(tra!$E$2:$E$1100,MATCH(G$3,tra!$C$2:$C$1100,0))),"",
INDEX(tra!$E$2:$E$1100,MATCH(G$3,tra!$C$2:$C$1100,0)))
I tried using G$3-1 but this doesn't appear to work.
View 1 Replies
View Related
Jun 16, 2014
In the four rows of text below I'm trying to match each gas stick to its corresponding gasline.
I think I can count over to "GAS STICK" and get the number. <15> From that point I can count over to "," (comma) and get that number. <26> So the gas stick will be between the first number and one less than the second number. <GAS STICK 1>
I need completing this code to place a the line or stick number in a cell B of the same row. Column A would have the description and column B of the same row would either be "1" or "11" respectively. Column C would be the shortened description (GAS STICK 1).
1] "HUNGA, DUNGA, GAS STICK 1, THINGY"
2] "DOHICKY, GAS STICK 11, THINGUS"
3] "SCAPPEN, DAPPER, GASLINE 1"
4] "SUCH, AND, SUCH, GASLINE 11"
[Code] .....
Attached File : ExactMatch1.xlsx
View 3 Replies
View Related
Dec 12, 2013
Using the dcount function it appears that the criteria is not exact. I have typed in ="IP" but instead of getting only IP. I'm getting cells beginning with IP, eg IPp and IPe. When I use countif I don't get this problem.
View 3 Replies
View Related
May 15, 2014
I has number sheets with thousands rows of unsort data. I need to find the price, with optional name and date if given, to return the rows values.
Example from Summary sheet, to find the price range and return 3 rows (even there are four set of answers, highlighted in light blue), with sorting the highest price first.
Summary Sheet
Sheet name
S01
S02
S03
S04
S05
S06
S07
Product
1
2
3
4
5
6
7
Search Fields
[Code] ........
View 1 Replies
View Related
Dec 9, 2008
I have the following snippet of
If Cells(3, k).Value = "Actuals" Then
DesActualColumn = Cells(3, k).Column
End If
nice and simple, and works fine until it cannot find "Actuals" in the cell because someone has put a tab ahead of it, for example.
Can anyone tell me how I can use a 'LIKE' and put wildcards
View 9 Replies
View Related
Mar 19, 2014
I have a file with duplicate names of test id's in col a. In col b I have single test id's and col c I have test names. I need to search col a for exact match of test id in col b and if it is there then put the name of test in col c into col d.
See attached document. Basically I need to know the name associated with the ID in column B.
View 3 Replies
View Related
Feb 27, 2014
On sheet1, I have numbers and names. These names are also contained in Comments on sheet2, and i would like a function in Column M that matches the numbers with the names in the comments. Cell M1 I have manually filled for demonstration purposes.
Can this be done with a function or is this a VBA task?
View 7 Replies
View Related
Jan 16, 2009
I have the following formula in a cell that gives me a sum of items matching certain criteria.
View 3 Replies
View Related
Apr 28, 2012
I am having such a difficult time creating a macro that will reduce the 5+hours I have to spend each week manually copying & pasting all of this data. I making an IMMENSE difference in this worker bee's life!
I have a workbook with two sheets (Sheet1 & Sheet2). Sheet1 has license #'s in column A and the state that the license belongs to in column B like this:
COLUMN ACOLUMN B11111Alaska11112Alabama11113Arkansas11114Arkansas
Sheet2 has three columns. Column A has the license #'s, column B has the state that the license belongs to and Columns C shows a line-of-authority tied to that license #.
COLUMN ACOLUMN BCOLUMN
C11111AlaskaProperty11111AlaskaCasualty11112AlaskaLife11112AlaskaHealth11112
AlabamaProperty11112AlabamaCasualty11113ArkansasLife11113ArkansasHealth11114
ArkansasLife11114ArkansasHealth12345ArizonaProperty
I'm trying to write a macro that will compare the license # and state in Sheet1 to the license # and state in Sheet2. If it matches, append the contents of Column C to the corresponding row in Sheet1.
Here's the thing...Sheet2 contains the entries for all licenses in the company (so this table is HUGE). And there are multiple entries for each state license # (notice how there's two entries above for AK license # 11111 - one for the Property line and one for the Casualty line.
After my macro is run, I want Sheet1 to show all the lines-of-authority on a single line. So if I ran my macro on the above example, after it's run I would have this in Sheet1:
COLUMN ACOLUMN BCOLUMN
C11111AlaskaProperty Casualty11112AlabamaProperty Casualty11113
ArkansasLife Health11114ArkansasLife Health
View 5 Replies
View Related
Mar 11, 2014
I am having some trouble getting a formula to work. I am building a report that pulls figures from a pivot table in another workbook. I am using a vlookup with match function to get the column index to find the relevant data I want. Where I need to add two columns together I am using sum, with the vlookup & match formulas nested in them e.g.:
=SUM(VLOOKUP(F13,'[PIVOT 156.xlsx]PIVOT'!$C:$AQ,MATCH("FAID",'[PIVOT 156.xlsx]PIVOT'!$C$6:$AQ$6,0),FALSE),VLOOKUP(F13,'[PIVOT 156.xlsx]PIVOT'!$C:$AQ,MATCH("COMM",'[PIVOT 156.xlsx]PIVOT'!$C$6:$AQ$6,0),FALSE),VLOOKUP(F13,'[PIVOT 156.xlsx]PIVOT'!$C:$AQ,MATCH("BPCM",'[PIVOT 156.xlsx]PIVOT'!$C$6:$AQ$6,0),FALSE),VLOOKUP(F13,'[PIVOT 156.xlsx]PIVOT'!$C:$AQ,MATCH("COMD",'[PIVOT 156.xlsx]PIVOT'!$C$6:$AQ$6,0),FALSE))
Where:
F13 = Employee number
Column C on the pivot 156 workbook is where the employee number is based.
The Match formula is then getting the column index from the column headings of the pivot table ie. "FAID"
This in itself works fine, as long as it finds a match in the column headings. This is where i get the error as in the above function "COMD" is not in the pivot table. However I need to keep it included as it may appear on a future pivot table. Is there a way of getting the sum function to complete even though later in the formula it can't complete the vlookup? So it will ignore it, or assume the value is zero if it can't find it? The formula probably needs to do this for all the vlookups as some headings may drop off in future pivot tables.
View 2 Replies
View Related
May 16, 2014
I have an 'Update' Module that search the value of the Userform1.txt_sc.Value in Column B, but I want to search to 2 criteria, how can i amend the below code to search for 2 criteria ( userform1.txt_sc.value & userform1.txt_linenum.value )
View 2 Replies
View Related
Jul 30, 2014
Here is the table I am working with
Date
Open
High
Low
Close
Volume
Adj Close
Semi-Annual Yield
Theoretical Bond Price
Index
Coupon
Total Value
Peaks
Troughs
[Code] ..........
The Relevant columns would be "Date" column A cell 1, "Total Value" column L cell 1, "Peaks" column M cell 1, and "Troughs" column N cell 1. What I basically want to do, in the next column, column O, is this: If cell N# = "Trough" find the previous M cell = "Peak" and take the L cell in that "Peak" row and subtract the L cell in the Trough row from it (like =(L4-L9)/L4)). Then in column P, if the percentage drop was 5% or greater, I want to find the days between the trough we are looking at, in cell n10, and the NEXT Peak, cell M11, using the corresponding dates in Column A.
View 3 Replies
View Related
Feb 14, 2014
I have a spreadsheet that contains data for a fiscal year broken out by month and quarter. I want the formula to return the data from that month and use whatever the latest quarter is. For example in the data below:
If it has only pulled data only thru Q1 it would return Q1 for Jan-Mar, however once I have Q2 data I would want the formula to return Q2 for the months of Jan-Mar.
2013Thru Q1STOLISTOLIJan-2013STOLI BASE
2013Thru Q1STOLISTOLIFeb-2013STOLI BASE
2013Thru Q1STOLISTOLIMar-2013STOLI BASE
2013Thru Q2STOLISTOLIApr-2013STOLI BASE
2013Thru Q2STOLISTOLIMay-2013STOLI BASE
2013Thru Q2STOLISTOLIJun-2013STOLI BASE
2013Thru Q3STOLISTOLIJul-2013STOLI BASE
2013Thru Q3STOLISTOLIAug-2013STOLI BASE
2013Thru Q3STOLISTOLISep-2013STOLI BASE
2013Thru Q4STOLISTOLIOct-2013STOLI BASE
2013Thru Q4STOLISTOLINov-2013STOLI BASE
2013Thru Q4STOLISTOLIDec-2013STOLI BASE
2013Thru Q4STOLISTOLIDec-2013STOLI BASE
2014Thru Q1STOLISTOLIJan-2014STOLI BASE
View 3 Replies
View Related
Jun 2, 2012
I am very new withe macro I recieve every day a CSV file from our supplier withe a list of the products that got updated withe new price, stock count, product ID etc.
I have my own worksheet with the product ID that we use, and I want to finde the exact match to my product ID in that CSV file and delete all other that don't match.
But i need them get deletede by rows thos product ID that dosen't match to my workbook.
I tried with this, so it could set an X in front of my match then i could filter and copy it to my workbook but it dosen't work:
Because the same product ID is sometime in 100 rows and the X come only in front of one of them.
=IF(ISNA(MATCH(Q2:Q1000;G$2:G$1000;0));"";"X")
so with some macro. I need to have every row deleted that don't match to my list of product ID.
View 5 Replies
View Related
Feb 23, 2008
I went through all the forums but confused a little. In the work sheet I want Excel to find an exact word such as letter "a" in all over the work sheet (not a column name) and paste it to the destination work sheet. I am attaching an example file, can some help me to solve the problem.
View 9 Replies
View Related
Nov 16, 2011
I'm trying to automate a search and match function between two separate workbooks using VBA and am having some problems. I'm using the following line:
search_results = Application.Match(temp, Range("E1:E900"), 0)
which works fine. now the problem is that when i'm searching for lets say "ABCD" in one of the workbooks, if there is an entry "ABCD " (with a space at the end) it says that the entry doesn't exist. is there any way of correcting it such that it would always neglect the space at the end if it exists? i tried using -1 instead of 0 and it messes up, so i'm not sure what to do.
View 2 Replies
View Related
Nov 28, 2012
Attached is a sample workbook, but essentially what I'm looking to do is automate the process of searching through a data set where the value of interest (in this case, names) often has multiple entries, with different values attached to each instance.
I would like to be able to get a list of all values in a given column that match a specific name in another column.
Currently I'm using a basic INDEX/MATCH search just to see whether the data exists at all, but that's only half of what I have to do here, and I'm totally stumped on how to get a comprehensive list of all matches.
For reference, if you look at the sample, what I need is a list of all values in the "CPT" column that match the name searched for in the first column.
The actual data set size is at most 3-400 entries, if that makes a difference in how to approach this.
CPT Sample Book.xlsx
View 4 Replies
View Related
Jan 29, 2006
Here is what I have:
Column J is the date opened. Column T is the date closed. Of course,
column T will have no date if still open.
Column K and O may or may not have text.
Column AF6 has a date, mm/dd/yyyy, that is entered/changed depending on the search.
What I need is a formula in AF8 that will look at the date entered in AF6 and find a match in columns J and T. Then it will look to see if there is text in K and O. If so, populate AF8 with that text.
View 11 Replies
View Related