Use Lookup Function In VB
Apr 22, 2009How do I write a code for the following Excel formula:
=LOOKUP(E20,{0,2501,5001},{"CatA","CatB","CatC"})
I tried the following but not working
How do I write a code for the following Excel formula:
=LOOKUP(E20,{0,2501,5001},{"CatA","CatB","CatC"})
I tried the following but not working
I have a workbook with 2 different types of sheet - 1 containing source data and the others 'collecting' data from the source sheet, depending on what the sheet is for.
For example, the data source contains different pets, their names, ages and their owners.
The other sheets are on a one-per-owner basis.
What I would like to do is use a LOOKUP / MATCH function to lookup the owner name typed in cell A1 of the output sheet and match it with the corresponding owner name(s) on the source sheet. I would then like it to return with each pet and append the results on the sheet accordingly - like below:
John Smith (in cell A1)
Pet - Name - Age
-------------------
Dog - Rover - 3
Goldfish - Tom - 1
Gerbil - Chewit - 4
I am trying to perform a lookup (vlookup) function in a cell in excel and wish to have the range as a variable, so that I can adjust which column the lookup function refers to.
View 4 Replies View RelatedI am trying to use lookup function to lookup for data in another table (we call it table A). Unfortunately, whenever the code is not in the table A, Excel will return the data from the previous row.... is there any possible way to prevent this... in another word, if the code does not exist in the table A, I want Excel to return 0 or some other figures.
View 9 Replies View RelatedIs it possible to set up a lookup function with two lookup values? For example, say I have a list of items such as:
1 A 14
1 B 22
2 C 84
4 D 25
I'd like to have the lookup go to the above table and find the number 1 and the letter B and return 22. I can't seem to visualize how to make this work.
Can I get all the information from Employee & Benefits tab to populate in the 401K worksheet. All information is on these two sheets except status, plan entry date, and 2009 compensation.
True under Employees tab means that a person is still active and I would like for that date to populate the 'Hire Date' column; whereas, 'False' represents a person is termed and I would like for the false date to populate under termed. Can you use the social security number if its a V Lookup because I have thousands of rows and multiple people with the same last name.
I would like to do is reference a table of data using the Vlookup function but add all of the results together. I have a table where I keep track of orders being distributed, and in an inventory sheet I want it to reference that table based on the serial numbers entered and total the results.
View 3 Replies View RelatedA B C D E
1 DAY 1DAY 2DAY 3DAY 4
2 AAA1638
3 BBB7325
4 CCC3847
5 DDD5562
This is what I have. Now I want to see, for each day which has the highest value. so it should return BBB for day 1, CCC for day 2, DDD for day 3 and AAA for day 1.The formula I am using:
=lookup(max(B2:B5),B2:B5,A2:A5)
=lookup(max(C2:C5),C2:C5,A2:A5)
=lookup(max(D2:D5),D2:D5,A2:A5)
=lookup(max(E2:E5),E2:E5,A2:A5)
Tell you what, it is giving me correct result for column B,C,D but not for E. The formula for column E should return AAA, but for some reason it is returning DDD.
I just wanted to use lookup function in my code. But I had to re-write my for..next statement 8 times. How can I state it in one single lookup function used in a for..next statement. Here is my code
Sub iteration(r)
Dim i As Integer
Dim j As Integer
Dim x1(4) As Double
Dim arra(8, 2) As Double
Dim arrb(8, 4) As Double
r(1) = Worksheets("sonuc"). Range("j4").Value
r(2) = Worksheets("sonuc").Range("j6").Value
Dim myRange As Range
Set myRange = Worksheets("giderler").Range("b6:b11")
x1(1) = Application.WorksheetFunction.Floor(r(1), 0.5)
x1(2) = Application.WorksheetFunction.Ceiling(r(1), 0.5)
x1(3) = Application.WorksheetFunction.Floor(r(2), 0.5)
x1(4) = Application.WorksheetFunction.Ceiling(r(2), 0.5)
For i = 1 To 4
I have 2 worksheets, 1 containing a list of 5000 products and 1 containing a list of 3 columns with classifications in them (about 300 classifications). for example worksheet 1 has 5 products
Coke
Volvic
Mars Bar
Cornflakes
Bags Maltesers
The 2nd worksheet has 3 columns with the following info
Column 1 Column 2 Column3
(Catagory) (sub Cat) (Sub Sub Cat)
Minerals Soft Drinks 2lts
Minerals Water 1lts
Sweets Choc Bars Std Bars
Sweets Bagged Lines Std Bags
Grocery Breakfast Cereals
I want to be able to add a classification to the products in worksheet 1. For example to be able to choose a dropdown that has a list of each classification
and after coke select from the "Catagory) drop down, then select the "Sub Cat" drop down and then select the "SubSub Cat" dropdown.
Product Catagory Sub Catagory SubSub Catagory
Coke Minerals Soft Drinks 2lts
Mars Sweets Choc Bars Std Bars
As I said I have to do this manually for about 5000 items so I need to be able to do this as fast as I can. Can you use the lookup fuctions or something like that?
how to fix the REF error in this formula. =IF((OR(G3="Hour (Truck)",G3="Hour (Truck + Dog)")),(VLOOKUP(G3,Rates!$A$186:$B$187,2,FALSE)),(IF(F3="Hanson",3.5,(IF(F3="Lakes",10,(IF(F3="NO",(VLOOKUP(E3,TonnesRates,MATCH(B3,Rates!$B$110:$D$110),FALSE))))))))). I have tried to attach the file with the minimal information in it to make it small enough but I can't get it below 48kb.
View 7 Replies View RelatedI have read through other similar topics and tried using the index and match function to lookup but been unable to make the formula work.
I am trying to use the lookup function to pull data from a table using criteria in two columns and one row. I have attached a spreadsheet for example.
I want to use criteria of Day (eg . 1), Total height (cm), and jar # (eg. 1). I inherited this table from a previous coworker and don't have time to organize the data better.
In the spreadsheet I want to return the value of 8.8 (highlighted in yellow). The criteria I want to use to lookup the value are highlighted in red.
The following Lookup-function does not work properly. Ay idea why? My Input in E13 is months.
=LOOKUP(E13, {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"},{"012","001"," 002","003","004","005","006","007","008","009","010","011"})
I am creating a spreadsheet to keep track of money and grouping them into categories. I have a column to group a purchase into a category (column E) and the amount spent in column F. I want column T to add up all of the purchase that were made according to the category in Column E.
View 2 Replies View RelatedI have store numbers and store volume groups (one letter indicating their sales volume). This is sorted in somewhat of a table - the volume groups are in row 4 going horizontal, the store numbers are under their respective volume groups going vertical.
I have all store numbers listed vertically on another sheet, starting in A2. I want to search for the store number in A2 within the volume group data and return the appropriate group header when it's found.
A
B
C
Ap1
queens Carrots
Goja Apple
Ap2
fujja Apple
fujja Apple
Ca23
Goja Apple
queens Carrots
I tried to write a function so that it would search for a word from Column C in Column B, and then when it found it, give me a a combined result of Column A and B. For instance. I lookup up C1 (Goja Apple) in the range of all of column B; the function finds it in B3 (Goja Apple); then it returns the combined result A3 and B3 (Ca23 Goja Apple). I tried the =lookup, but I think the first column you select must be in ascending order, and that wont work for me.
In my spreadsheet, one cell in every row has a string that contains the invoice number. I would like to get the invoice number in a cell of it's own. The problem is that different vendors use different lengths of characters for their inv #, so I can't do a one size fits all MID formula.
What would be the best way of getting the invoice number?
I'm trying to set a range to use in a Lookup function but it's not working. I've done this other times with no trouble and I don't see why it's not working now.
If Target.Row > 2 And Target.Count > 1 Then
For Each c In selection
If c.Column = 11 Then
' confirm that Activity ID is in the Reference file list
Set Lookup_Vector1 = Worksheets(c.Worksheet.Name).Range("Activity_ID")
Error occurs on the Set Lookup_Vector1 line, Run-time error '1004': Application-defined or object-defined error.
The range Activity_ID is defined in the current worksheet but exists in another workbook. The c.Worksheet.Name correctly gives the name of the worksheet where the range is defined.
Look at 6 weeks of data, using "Tue" as the search parameter. I need to find the last 3 tuesdays (from current cell) and then sum the corresponding values in the cell I designate.
I'm fluent with LOOKUP and already have it finding and summing last few Tuesdays and corresponding sales totals, but I need it to only back THREE Tuesdays consistently, not 2 or 4, which it is sometimes doing now??? How do I force it to look back at "tue" and when it has found three times, it knows to stop and not consider any other Tuesdays it may find further back in the data?
i use the formula below in a wb. When it runs its searches col A for what ever is in H36. Is there a way to make it search col A & B for what ever is in H36?
=IF(ISNA(VLOOKUP(H36,'PRICE-GAS'!$A$149:$N$6000,5,FALSE)),0,VLOOKUP(H36,'PRICE-GAS'!$A$149:$N$6000,5,FALSE))
Im just setting up a spreadsheet for structural timber design calculations. One of the requirements for this spreadsheet is to look up a Zx value from a table. Once the Zx value is found it returns a size of timber from another column. I have managed to create the function so that it looks up the Zx value and returns the size. However, if the function cant find the exact Zx value, which will usually be the case. The next lowest Zx value is used. Is there a way i can edit this function so that it returns the next highest Zx value instead of the next lowest. At the moment this is the code i am using.
= LOOKUP(Q92, 'Zxx Table'!E5:E172,'Zxx Table'!C5:C172)
Where Q92 is the value to be looked up. E5:E172 is the column of values to be searched. C5:C172 is the column of values where the result comes from. In addition to this just to further complicate things, can it return say the next 5 highest values? If a lookup function cant be used could you tell me another way that i can achieve this.
Im trying to do a lookup but when I drag the formula down it returns the wrong values and also returns #N/A or #REF (which I think means it's refering to a wrong range and cant find the data???). How can I do a look up function by dragging the formula down a long column of data eg. 65,000 rows in excel, that returns the correct text. I have attached a simple example- see attached.
View 4 Replies View RelatedI need to add a Bloomberg BDP function to my lookup statement. The formula that i'm trying to replicate in VBA is =IF(ISBLANK(h23,"",BDP(H23&" cusip","long_comp_name")). update my macro.
View 9 Replies View RelatedI have been writing a speadsheet using drop down lists and the Lookup function to link names to body weights. When using the dropdown list it displays for one name the incorrect weight. All the rest work correctly but one will not. From the list below when I select the name White it displays '68' rather then '80' as it should. If I change the name of White to the number 4, it will act correctly and display the weight '80'. It seems rather bizare.
This is the function that I am using
=LOOKUP(C53,Weights!B2:C9, Weights!C2:C9)
Pilot
Jones
78
Smith
95
[Code] .....
Nano Caps are companies with a market value below $50 Million
Micro Caps are companies with a market value between $50 Million and $300 Million
Small Caps are companies with a market value between $300 Million and $2 Billion
Mid Caps are companies with a market value between $2 Billion and $10 Billion
Large Caps are companies with a market value between $10 Billion and $200 Billion
Mega Caps are companies with a market value above $200 Billion.
I have this part so far that someone helped me out with that belonged with this criteria:
Micro Caps are companies with a market value below $300 Million
Small Caps are companies with a market value between $300 Million and $2 Billion
Mid Caps are companies with a market value between $2 Billion and $10 Billion
Large Caps are companies with a market value above $10 Billion
=LOOKUP(P2,{0,300000000,2000000001,10000000001},{"Micro","Small","Mid","Large"})
I came up with this one for the new criteria:
=LOOKUP(P2,{0,50000000,300000000,2000000001,10000000001,200000000001},{“Nano”,"Micro","Small","Mid", "Large",”Mega”})
it keeps giving me an error message..... the thing is the criteria that its based off of( market cap) is in millions but this is the function thats in the cell: =K2*T2/1000000
I have data concerning documents people have to write, which is updated weekly. Is there a way of looking up a name and then returning all the documents that they have to write. I have tried a vlookup, but this only returns the first entry and not the lot. Also i would prefer the document data for each person to be returned in to one cell.
View 3 Replies View RelatedI am currently using the following formula:
=SUMPRODUCT(('Step 1_Data_Current Qtr'!T2:T10000=B2)*('Step 1_Data_Current Qtr'!C2:C10000<>"")*1)
...to count the number of instances in a data set where:
T2:T10000=B2 is counting records where the value in the cell is set to B2
and
C2:C10000<>"" is counting records where the value in the cell is not blank.
The current formular is working, but I want to change the formula so that the values in C2:C10000 is looking up specific names (in this case, physicians) and not just where the field is not blank. How can I change to lookup physicians in a specific list that may change, located in a separate tab from the main data set?
I have table product that include (wide 1,wide 2,thick 1,thick 2,long 1,long 2,Price) And I have table transaction than have wide, thick, long and price)
I want that price in table transaction fill automaticly from table product where ( wide between wide 1 and wide 2 ) and
( thick between thick 1 and thick 2 ) and ( long between long 1 and long 2 )
excelformula.gif
pricing.xls
I've forgotten all the formulas that I learned during college. And that was for Excel 2003; now I'm using Excel 2007. So, hopefully you experts can help me out.
So here's the problem. I need to set up an invoice in Excel but I don't know what formula to use. I'll first describe my invoice and then I'll tell you the problem.
It's a basic invoice where you have customer's info and product's details and prices. So, when I choose a customer's name from a list in a cell, the address and phone of that customer will automatically appear. I don't have a problem at all with this part. And then there's the product details section where you enter a product type, size, color, price per unit, and total price. The price per unit also depends on the customer entered. Each customer has different pricing and I used a discount system for each customer. We basically have a universal price list for our products, but we have different discount percentage for each customer.
My invoice will look something like this: ...
I simply want to use the indirect function in vlookup formula in cell B2 (sheet11) is the sheet name I want to use for the lookup table.
=vlookup(B1,'[Alan.xls]sheet11'!$A$5:$F$19,4,0)
=vlookup(B1,'[Alan.xls]indirect("&B2&")"'!"$A$5:$F$19,4,0)
But doesn't work.