forward backward analysis using VBA code- - search

want to write code if there is specific value present in column "A" then match value from different column but same row with its above and below ten value. if value match then write "Match" f front of every match value

Related

Find same value in different column and print data of adjacent column using VLOOKUP

I have 4 columns "Column1", "MOVIE_ID", "AVERAGE_RATING" and "RESULT".
I want to check if the row in Column1 has the same data in "MOVIE_ID", and if the data is the same, I want to print show the AVERATING_RATING data again in "RESULT".
For example: if A2 matches any data in MOVIE_ID (in this case it will match B11), I want to print the adjacent AVERAGE_RATING (C11) in the result (D11) which is one the same row of the found MOVIE_ID.
I have this currently =VLOOKUP(A2;$B$2:$B$5001;3) but it doesn't work and I'm not sure why.
This is not easily possible, in the way you ask, because you want to use a variable field in the column A to match a field in the column B and display the result in the same row of B. But you cant set a variable result cell. So the result will be displayed in the cell where the function is.
But fortunately we have an equality relation, so we can switch the variable field and the search column. So we got the function:
=VLOOKUP(B2; $A$2:$C$11; 3; FALSE).
B2 is the variable lookup value.
$A$2:$C$11 is the constant Matrix.
3 is the column index (beginning by 1) of the result value.
FALSE is for a exact match.
So the value of B2 will be searched in the column A.
IF there was a equal value found, the value from the C column will be displayed as a result
ELSE #N/A will be displayed.

Lookup next column if lookup value begins with certain string

I am trying to match a value in an array. If the lookup value begins with any value in the table then it will return the value in the next column. The problem is that each value in Column A is of different length.
Is it still possible to match it in Excel without using VBA?
Try looking up the "most demanding" string first (most characters) and if not found (ie an error), look up progressively shorter strings, eg:
=IFERROR(VLOOKUP(LEFT(D3,4),A:B,2,0),VLOOKUP(LEFT(D3,3),A:B,2,0))

Comparing 2 columns in excel to highlight match and difference

I try to match data from my bank statement and data from my erp. The excel looks something like this:
I want to select the transaction number given in ERP data column and search it in Bank data column. If there is a match then concat the matched data and print in column D, else print the unmatched data in column E.
I am trying to use
=IF(ISERROR(MATCH(B2,$A$3:$A$30,0)),"",B2) but it's not giving appropriate results.
You can use this to return a value. I changed IF(ISERROR... to IFERROR function which returns the value of first argument if there is no error or the second argument if error occurs. I also used INDEX to get the value from column A and concatenate it with value from B.
=IFERROR(INDEX($A$3:$A$30,MATCH(B2,$A$3:$A$30,0)) & " " & B2,"")
This is formula for column D. In E you just need
=IF(D2="",B2,"")

2nd Smallest value based on criteria

Aim: I have all distinct names (in this case column K) and want to search down my list, column D. When I find D and K match I want to find the 2nd smallest value in E and show this value.
Code so far: =VLOOKUP(SMALL(E:E,2),D:D,1,K4)
Closest, but without Small filter =VLOOKUP($K5,$D$2:$E$999,2,FALSE)
Errors is #Value (and I can see there are actual values)
Also tried: =VLOOKUP(IF($D:$D=$K5,SMALL($E:$E,1),"X"),D:E,2) - does not filter criteia
Use Aggregate:
=AGGREGATE(15,6,$D$2:$D$9/($C$2:$C$9=$F4),2)
The 2 at the end tells the function to return the second smallest. Change that to 1 for the first.
The columns are based on your data in the screen shot. It assumes that the first column is A and the first row is 1.

Clarification regarding lookup value in the lookup array

I was analyzing MATCH function and used the function in the following way:
=MATCH(REPT("z",4),Sheet1! G:G)
Syntax for MATCH function is MATCH(lookup_value, lookup_array, [match_type])
Here lookup value is REPT("z",4) and lookup array is Sheet1:G:G.
REPT("z",4) evaluates to "zzzz"
MATCH function is giving me number 21 and it corresponds to last filled row in column G. If I fill the cell G22 then the function gives a value of 22.
Cell G7 already contains the string "zzzz" . My doubt is why I am getting 21 instead of 7 where there is already a matching string.
My level is basic in Excel and request experts help in clarifying whether above situation is meant to find the last filled row in the column or the purpose of match function is to find matching string value in the column range.
By not specifying the match type excel searches for the last entry that is smaller or equal to the lookup value. In your case, if you put a value (or in your case string) smaller or equal to "zzzz" in the last cell of the row, the formula will return the number of the last row. Therefore, if you don't declare the match type, the lookup array should be sorted ascending. If you want to return the first exact match, you should use the match type "exact match".

Resources