Close Window

Multiple Criteria Vlookup In Vba Userform

Hello all,

I have a problem with vlookup, some of the items in the lookup array are not unique and vlookup gets confused with multiple matches,

however if I can use a combination of 1st and second columns as the criterion then it would result in a unique match.

Problem is I don't know how to acheive this in vba (but I can with the worksheet formulas).

Any advice? (attached is a sample worksheet)

Free Excel Courses

Similar Excel Tutorials

This tutorial shows you how to use the Vlookup function across multiple worksheets within Excel.  This means that y ...

How to sum values that equal one of many potential criteria; this is basically summing with an OR condition. This ...

How to use the VLOOKUP function across multiple workbooks in Excel. This will create a link between the workbooks t ...

The SUMIFS function allows you to sum values that meet multiple criteria across multiple columns. Each value that ...

Helpful Excel Macros

- This UDF is a Vlookup function that searches the entire workbook in Excel. The syntax and usage of the function is exac

- This Excel Macro works like a better Vlookup function because it returns ALL of the matching results. Run the

- This Excel macro allows you to filter a data set on multiple columns and criteria at once. This means that you can filt

- This is very similar to the other Vlookup type Macro in that it returns all of the results that match a particular se

- This free Excel macro filters data in Excel based on multiple criteria for one field in the data set. This macro uses t

Similar Topics

Hi, can anyone help me with the below...

Im looking for a vlookup formula which will give me the maximum number from a list which contains multiple matches, i.e.

Lookup number 1 from column A, then give me the largest number from column B

example table:
1 5
2 2
1 11
3 2
4 5

the result would be 11

thanks all!

I have a very simple pivot table that I am trying to use as a data source for a VLOOKUP request. Unfortunately, every time I do it I get the result #NA. I have tried recreating the results from the pivot table in the worksheet next to it, and am able to use VLOOKUP on them successfully, but as soon as I point the VLOOKUP array to the pivot table, I get the #NA result

Can VLOOKUP be used on pivot tables? If so, is there any special syntax I need to use?


I am trying to write a formula that uses both an if statement and a vlookup statement.

It's for a house cleaning price list, with two sets of prices. I want the formula to say if the value in E7 is R, i want to lookup the value for the house in the second column. If the value in the cell is anything else, i want to lookup the value for the house in the third column.

So in sense, my formula should look like =IF (E7=1,"=VLOOKUP(A10,'Clean Prices'!$A$2:$C$58,2,FALSE)","=VLOOKUP(A10,'Clean Prices'!$A$2:$C$58,3,FALSE)")

But it doesn't work. Is it possible to nest a vlookup in an if statement?

I have entered a vlookup formula in a cell and it returns the correct value from the other worksheet. However when I copy the formula down it keeps returning the exact same value as the first cell. If I enter a formula in each individual cell it returns the correct value. Its driving me crazy ! I woyld be glad of any advice

Many Thanks


Hi Guys

I have the following in G2:


The formula returns the correct result, which in this case is a number - 2

When I fill down my range, the formula copies correctly, but every result is the same. 2.

However, if I go to the next cell down (G3) and activate it by pressing F2, and then hit Enter, the result changes and is now correct.

Any ideas whats going wrong?

Hi everyone....this is my first post here ....and not my last I believe!

My question I believe is easily solvable for you cracks of excel.
I have a worksheet with a list of rows (item#, date, price, etc). In the last column of this list I can put an x for some of the items.
On another worksheet or sheet, I need to autoamtically have a list of the items in the first list above, that have an X in the last columns.
I created an example on a worksheet attached just for you to understand.
I apreciate all the help I can get.
Thank you so much.

I have a textbox in my userform where anything typed in the box is entered into cell A2 in my worksheet. However, multiple lines of text are not properly displayed in my worksheet. I have enabled MultiLine and EnterKeyBehaviour in the properties window of the textbox so I can type multiple lines in my textbox. The problem is that when I press the button to enter the text from my txtbox to cell A2, the cell doesn't actually display the text in separate lines. It just places a square symbol in the place that enter should have been pressed and the text should have been split into separate lines.

How can I get the separate lines of text in my textbox to be properly displayed in a cell? Thanks for your help in advance..


I would like a formula that would list all the items in row B that match the criteria in row A. the first cell with formula would list the first item, the second cell with the formula would list the next item, and so forth. Also, column B might have a duplicates that should be listed. Is this possible? I cannot manipulate the order of the original items (ie, filters) because this data is being used to derive other formulas.

I have set a VLOOKUP formula to match account numbers. How ever I have to
click double click on the cell before the formula recognises the account
number. I have to do this for each cell. I have tried different formats. It
is not saving me that much time.

Is it possible to import a single text file into Excel, splitting the incoming data across multiple worksheets rather than a single worksheet? Each each row on the text file would be evaluated by the value in one of it's "columns" and written to the appropriate worksheet. The file is "!" delimited and has 11 columns for each row.

Currently, I import the file into one worksheet and cut/paste the rows manually into new worksheets/tabs. The files are very large, sometimes exceeding the 65,536 row limit, which I could avoid if the data was split out coming in.

Any help anyone could provide would be WONDERFUL. Thanks!

Hello Everybody,

I am hoping for some assistance. Here is what I have....

I am trying to get counts of certain values.

This is in the same workbook but different sheets.
On sheet 1 is where my formula lies. In a cell, I want it to look at sheet 2 column B and look for instances of "A", then I want it to look in the same row it found "A" and look at the value in column "N" and evaluate if there is an amount. If there isn't skip it and don't count it, if there is a value count it if it falls within a given range.

An example of the formula is below...what am I missing?


Thank you in advance for your assistance.

I just worked with a data set where I needed to create a unique key based on existing information where no unique key was set up as a field. I accomplished it by concatenating (using the & [concatenation] operator) several fields based on what I hypothesized and observed about their content.

I'm thinking there has to be a more automated way to discover the best unique key of existing fields and their data. I thought I'd post this as a challenge because I don't know the "right" (or better) answer.

Anyone have any ideas?

I have looked over the forums for information on how to do this, and can not find anything. I have used conditional formatting to identify duplicates in my spreadsheet. I have a unique user ID, which combines the first and last name fields into one. However, in 10,000 there are a number of John Smiths, Joe Adams, etc. With smaller lists, we search manually, and then add a 1, 2, 3, etc to each duplicate to create a unique value for the User ID.

My question is:

Is there a way to check for duplicates, and then automatically add numbers to the duplicate values to make them unique? If so, how can this be done?

So that you will have this:


I think I have done a good job in illustrating what I would like to be able to do, but if there is still something that is unclear, I will post whatever clarification is needed.

Thank you in advance for your help!!

is it possible to put two formulasinto one cell?

On the attached timesheet there are columns IN, OUT, IN,OUT
The lunch time is worked out by deducting 'C8 from C9' and this works fine when all 'IN, OUT' cells are filled in but for some reason when just the first two cells are filled in it gives a -12 hour answer.

looking at cell 'C11 ' in the attached worksheet, I currently have the formula
=IF(C13=0,","SUM(C9-C8)) The reason for this is to make it look tidy by having blank cells until a calculation is needed,, My problem is, If someone just comes in for the morning one day for instance 8am to 12 noon then they won't have lunch, but C11 will show -12:00
Can I put another formula into C11 to tell it not to deduct C8 from C9 until a time is put into C9.
The following is the sort of thing (many variations) I have been trying but because I'm hopeless at formulas I'm not having any success


I have workbook in which I want to save a specific worksheet to a new file with only the values saved - all data in this worksheet are references to cells on another worksheet, which is using VLOOKUP to pull data from a database.

Found the following code and it gets me close, but it copies the cell references, not the values. It also allows me to specify the file name from a cell reference.

I want the new workbook file to simply be saved, not opened, and a message box to display stating where the file was saved (will always be in the same location on the LAN).

What modifications do I make to this to get this to work per above requirements?

Sub CopyMe()
Dim SaveMeAs As String
SaveMeAs = Sheets("Sheet1").Range("B2").Text
ActiveWorkbook.SaveAs Filename:="C:\My Documents\" & SaveMeAs
End Sub

I have set up an excel file that helps put together different text components using the vlookup and concatenate formulas for use in one plain text document .

When I try to paste the finished result into notepad/textpad/word it adds extra double quote marks throughout the text. Does anyone know how to paste it without these marks?


I'm unable to group/ungroup rows or columns on an excel worksheet that was
emailed to me by a co-worker. It's an existing file so I don't know what
restrictions were placed on the workbook. What can I do to fix this problem?

Hi...hoping someone can help with a grouping problem.

I have 50 rows that I want to group. Rows 1-10 should be a group, 11-20 are a group, etc. The problem is, when I group 1-10 and then group 11-20 seperately, excel automatically makes 1-20 a single group and removes the individual groups that I wanted.

Any ideas?

Thanks in advance!

I'm trying to come up with a solution to calculate the man hours and days worked over multiple sheets.

I have a file that has 8 sheets. the first seven sheets are the days of the week and the 8th sheet is where I want to calculate the hours.

The days of the week consists of "Name" "Date" Hours"

The 8th sheet consists of "Name", "Days of the week in their own column (7 columns in total)", "Total Hours" and "Total Days Worked"

Now... each day is always a different group and what I'm hoping for is to create a formula that can grab each name with their hours and throw them into the 8th sheet. So when the end of the week is done I have all the Employees weekly hours and days worked all finished.

I hope this makes sense. This file is to track about 100 employees that are on a rotational work schedule.

I have attached a sample file.

Thanks in advance for your help.


I am brand new to Mr. Excel and would love some advice.

I searched the boards pretty extensively but could not find what I am looking for...I apologize if this is a duplicate.

I am using Excel 2007

How do you automatically add rows and update values for cells to a linked worksheet in which rows have been added? For example: Sheet 1, columns A & B are linked to Sheet 2, columns A & B. Sheet 2 has values in A1:A5 & B1:B5 and Sheet 1, since it is linked, has the same info. I want to add a row in between 3 & 4 on Sheet 2 and want Sheet 1 to automatically add the same row and update the value of the cell in column A & B.

Any help is greatly appreciated!



I have three columns containing last name values from 3 different sources that I've brought into one sheet. I am trying to find a way to compare all three values to establish if they are the same.

Of the three values there is no master, Each value may be different. So essentially it would be like doing =IF(a1=a2=a3,"match", "nomatch")
But of course this isn't possible.

I don't care about obtaining detail about which value matches which. I just need true or false response as to whether all three values are the same or not.

Thanks for any help anyone can provide.


Is it possible to apply a filter to multiple sheets within the same Excel workbook, using the same filter criteria?

For example, suppose you have tables of data on 3 different tabs, all having the same headings. Suppose one of the headings is "gender". If you apply a filter to the table on Sheet 1, to only show the rows containing the word "female", is it possible to have the tables on Sheets 2 and 3 automatically update to only show the "female" rows? Or would you have to manually update the filter criteria in Sheets 2 and 3?

I hope this makes sense. Thank you in advance for any help.


I'm pretty new at VBA and was wondering if you could help me out on this:

I have created a VBA userform but will need to have it used by at least 5 users. My question is, can it be done with all users working at the same time and when saving their work all data entered will go to one master excel sheet? if yes, would you be kind enough to share the code?
MS Access is not an option for me so I was wondering if you could help me do this in excel.

thank you so much and would really appreciate to hear from anyone soon.

I have never really used VBA and so am completely stuck at this problem. I need to create a macro which auto-populates a master worksheet from the individual user sheets in a shared workbook.

Sheet 1 is the master sheet "Team Stats". There will be an undetermined number of individual worksheets to accomodate new staff.

Each worksheet will be identical, using columns A-I with row 1 having the headings:

Date, Name, Reference, Value, Price, Age, Purchased?, Destination, Add. Products (the last 3 columns will have a drop-down list which will be used to enter data into the cell).

There will be a varying number of rows in each of the individual sheets.

If possible I would like the macro to run every time data is entered into one of the individual worksheets. If this is not then it would be fien to update every time the workbook is opened.

If anyone can help it would really cut down the time I spend collating these stats every day!

I'm comparing 12 cells on different sheets (in the same workbook) and need to determine if they are all an exact match to one another. Basically, I want something like exact(), but I need to compare more than two strings. Any ideas?


Related pages

excel error not enough system resources to display completelyimport html table into excelexcel substitute formulaword vba userformpercentage charts for weight liftingvba set cell colorfedex weight calculatoruserform command buttonpivot table multiple sourcesdeveloper tab in excel 2007excel fvsunrise sunset times graphexcel conditional format textrounding errors in excelhousie game number generatorcalculating the mean in excelvba call procedurealphanumeric sortexcel spreadsheet watermarkexcel 2007 autofilterexcel randbetweenvba query excelremoving duplicates in excel 2007linear depreciation formulaconvert cmyk to rgb formulaxls to qif converterhow to calculate cagr in excelvba object browservba delete file in foldermicrosoft excel runtime error 1004random 4 digit number generator in excelcylinder liquid volume calculatorvba millisecondsxor calculator hexexcel vba range addresstv show rundown templatevba line feed characterrunning a regression in excelvba quotefuzzy lookup add in for excelsquare root sign in excelhow to drag in excel without mouseunprotect sheet command excelhow to find difference between two columns in excellist of state abbreviations in excelfan chart excelexcel 2010 identify duplicateshow to lock scroll in excelvba clear clipboardcalculate hours between two dates and times in excelautorun macroexcel vlookup offsethow to use wrap text in excel 2010cash denomination sheeterror 0x80010105credit card reconciliation templateleap year calculation formulavba multidimensional arrayalt f8vlookup mrexcelexcel recalcexcel round up to nearest whole numberexcel vba sleepxml mapping in excelmeeting template excelmiles per gallon to litres per 100 kmquartile function excelexcel combine multiple worksheetsbyref argument type mismatchsplitting cell in excel