Please help me,
Take for example I have the following set of data:
Column A (Sheet1) | Column B (Sheet1) | Col. A (Sheet4) | Col B (Sheet4) | Col C(Sheet4)
----------1A2B----|---------1111------|-------1111------|--------AAAA----|------ABAB----|
----------2B1A----|---------2222------|-------2222------|--------BBBB----|------AABB----|
----------1B1B----|---------3333------|-------3333------|--------CCCC----|------AABB----|
I already have developed a function code that will find the corresponding value of Column B in sheet 1 to the column A in sheet 4. For example my code will automatically return the values AAAA & ABAB if for all 1111 values in Col B on Sheet 1.
The problem is that if the value in Col C Sheet 4 equals to AABB, i have to perform another search within another table (for example the table is located at sheet 5). And this time the basis of my seach will be the Col A on sheet 1 because Col A has its own mapping. So i have to perform another search. Can someone please help me with this. I am a newbie when it comes to excel vba. Oh and by the way it has to be on excel vba.
So for example if my code sees the value 2222 on sheet 1 Col B. It will be like this:
Column A (Sheet1) | Column B (Sheet1) | Col. A (Sheet4) | Col B (Sheet4) | Col C(Sheet4)
--------------1A2B----|---------2222----------|-------2222--------|--------BBBB-----|------AABB----|
The code will see the AABB and it will perform another search using the 1A2B code. The 1A2B is mapped to another table.
Please help me.
Sounds like you should use the VLOOKUP worksheet function at both levels. You can use the function in VBA with the following:
Application.WorksheetFunction.VLOOKUP(value to lookup, range to look in, column # to return data from, FALSE)
Related
A |B |C |....|K |L |M |
Tom |0 | |....|Tom |Jim |Dave |
Jim |1000 | |....|15000|14000|12000|
Dave |3000 | |....| | | |
Using Google Sheets for this one. I would like the values in columns K, L, and M to read from column B, detect if the corresponding cell from A reads one of 'Tom', 'Jim', or 'Dave' for example, and then subtract the amount from the correct column to reduce a running total. I've had some trouble figuring it out and tried to use conditional formatting to solve it but can't seem to quite get there. Is there a formula I can use that will read column B and subtract the amount shown from the correct column based on the name in column A?
So to pseudo-code it:
read(column B cell);
if(column B cell - 1 column = "Tom")
{
column K - (value of column B cell)
}
else if(column B cell - 1 column = "Jim")
{
column L - (value of column B cell)
}
etc.
Is there a simple method I can use to generate this result? Also thought about changing the formatting of a cell based on the name in the cell next to it and subtracting the value of any cell with that colour but this becomes unwieldy if names are added. Any assistance would be greatly appreciated!
would there be a way to constrain the formula to a single cell so I can have the total in a single location rather than down the columns? My plan is to have the total boxes scroll with the sheet and always be visible.
Let's assume that Columns A and B continue on down the sheet, with further name + amount entries. You want to have a single row of balances for each of the people.
The balance is then some initial value less the sum of amounts for that person. Say the amounts you've shown in row 2 are the initial values; here's how you could have row 3 reflect the remaining balance for each person (This is for "Tom", copy for the others):
=K2-sumif($A$2:$B,"="&K$1,$B$2:$B)
Alternative solution
This doesn't do exactly what you want, but it is more appropriate for a running total scenario, so others may find it useful to adapt to ledgers, etc.
The IF() function can be used to decide whether or not a value in Column B applies to one of the "total" columns, K to M.
Use this formula in K3, copy to the rest of the range:
=K2-if($A2=K$1,$B2,0)
This example is in Google Sheets, but the same formula works in Excel and other "compatible" offerings.
What you do is put the formula in each column.
Column K subtracts value of column B if column A = "Tom"
Column L subtracts value of column B if column A = "Jim"
etc
I asked a very similar question to this one here, but I am trying to identify if a cell's numerical value is contained in a list of cells on a different sheet. If the cell from sheet A matches a cell in sheet B, mark a different column in B with a corresponding row in sheet A, otherwise leave it blank. An example is below:
Sheet A
Column A | Column B
-------------------
1 John
2 Sue
4 Bob
I would like the corresponding Sheet B to populate Column B like this:
Sheet B
Column A | Column B
-------------------
2 Sue
3
4 Bob
=IF(ISNUMBER(MATCH(I2, 'SALT, WOD, Champion Members'!A:A, 0)), "Y", "N")
I have been using the above answer to populate a different column in the same workbook, and I'm thinking I can maybe use this formula, but instead of "Y" or "N", somehow preserve the row.
You need to use VLOOKUP as already mentioned. But you will need to use another function to check for existence of the value, else you will get #N/A against ID 3
I used COUNTIF
=IF(COUNTIF($A$2:$A$4,E2)=0,"",VLOOKUP(E2,$A$2:$B$4,2,FALSE))
Use the VLOOKUP function:
=VLOOKUP(A1;Sheet1!A:B;2;FALSE)
Where A1 is the value you want to look up, Sheet1!A:B is the original sheet with the data.
I'm wondering if someone would be able to offer some advice on the best way to do this please:
Data in Worksheet # 1
Col A | Col B | Col C
Part-1 | 8 | 2
Part-2 | 7 | 7
Part-7 | 9 | 4
Part-8 | 2 | 6
Data in Worksheet # 2
Col A | Col B | Col C
Part-1 | 8 | *Return value* (If Part-1 is found and 8 matches, return 2)
Part-2 | 7 | *Return value*
Part-3 | 8 | *Return value*
In Worksheet#2 in Cell C2 - I would like to check if the Part-1 in A1 is found in Col A in Worksheet#1. If it is, then I would also like to make sure the Number is B2 in Worksheet#2 matches the Qty in Col B next to the same part#, if both the Part# and Qty match, then i would like to copy across the value from the corresponding cell in Col C in Worksheet#1, to Col C in Worksheet#2. If it does not match, I would like it to return a 0.
Here is the a variation on Reinier's second approach in a form that will work in any version of Excel. You can use references to the specific data ranges, as I have done here, or to entire columns.
=SUM((A2=Sheet1!$A$2:$A$5)*(Sheet2!B2=Sheet1!$B$2:$B$5)*Sheet1!$C$2:$C$5)
This is an array formula, so it needs to be entered with the Control-Shift-Enter combination. It performs the same operation as the SUMPRODUCT. (There are several other ways to do this, such as using MATCH with INDEX or OFFSET.)
Essentially, what you are doing is a lookup based on values in two columns. Looking at it from that angle, you can use a the SUMPRODUCT function, which is supported in any version of Excel. Enter the following in Sheet2, cell C2:
=SUMPRODUCT((Sheet1!$A:$A=$A2)*(Sheet1!$B:$B=$B2)*Sheet1!$C:$C)
Select and drag down the right-bottom corner of C2 to complete column C.
This only works by virtue of the fact that the values in Sheet1, column C, are numbers. It breaks if value pairs in column A and B of Sheet1 occur multiple times, but you did not address that situation in your question in the first place.
For versions 2007 and up, you can use the more convenient function SUMIFS with basically the same approach:
=SUMIFS(Sheet1!$C:$C,Sheet1!$A:$A,$A1,Sheet1!$B:$B,$B1)
Alternatively, you can use a combination of IF and VLOOKUP functions. A formula that will work for Excel 2007 or newer is the following:
=IFERROR(IF(VLOOKUP($A1,Sheet1!$A:$C,2,FALSE)=$B1,VLOOKUP($A1,Sheet1!$A:$C,3,FALSE),0),0)
Older versions of Excel do not support IFERROR, but you can still use a similar approach as explained here.
I have uploaded an example workbook here, which includes an alternative method in column D of Sheet2 as well.
I need to sanitise a mailing list, and am wondering if anyone knows of a formula to find out the following:
I have an excel spreadsheet with two columns A and B, the formula I need to do is: if [value in column B is duplicated] has [blank in column A] AND [data in column A] then show the value of Column B in a new Column C.
Example of data:
COL A | COL B
11/11/12 | **name#example.com**
03/09/11 | different#example.com
| **name#example.com**
06/01/12 | anothername#example.com
The formula would detect name#example.com is duplicated & it has a date in column A & further on has no value in column A, and therefore displays: name#example.com in Column C.
Hope that makes sense!
This should work (obviously changing the ranges to cover all rows):
=IF(AND(COUNTIF($B$2:$B$5,B2)>1,A2=""),B2,"")
I have the following csv file:
name, new_name, flag
a,,0
b,,1
c,c,0
d,,1
I want to make the value in the "new_name" column become the value of the "name" column in rows where the "flag" row has a value of 1. Do I have to use an application program to do this? or is there a way of putting this equation into the "flag" column and then pasting the formula in every row in that column?
Much thanks in advance!
If you can live with a four-column setup:
name | new_name | flag | real_new_name
a 0
b 1 b
c c 0 c
d 1 d
then you can set real_new_name to the formula =IF(C2=1,A2,B2) and fill it down.
Otherwise, you will need to write a script that goes through each row and acts if flag=1.