Excel Assign a value to a column if that row is flagged - excel

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.

Related

scan Excel column based on another column value

I want to check one entire column with value in another column and then assign a value in another column value to matching row cell.
Eg-
A B C D
1 10 X
2 3 Y
3 2 Z
4 11 K
What I want to do is take one value at a time from column A eg 1 and then scan through Column B if matches the Column A (value 1) then assign x to that row under D. eg if we check A3 ( value 2) with column B and found 2 is on B4 then D4 = Z. Like this I want to check all values in column in A against column B assign relevant vale from column C to Column D
How can I do this, can someone please help me.
Thanks.
Try:
= IFERROR(INDEX($C$2:$C$5,MATCH(A3,$B$2:$B$5,0)),"no match")
See below.
Try:
=IFERROR(VLOOKUP(A1,$B$1:$C$5,2,0),"")

Counting instances across ranges in columns

I am creating a spreadsheet for my personal use. I need to count the number of times one column's values are equal to an adjacent column's.
Is there any way to do this in Excel without having to modify the formula every time a new row is added?
If you have column A and B now, add column C:
Column A Column B Column C
1 2 =countif(B:B, A1)
2 2
3 1
Then just copy the first value in column C, select the entire column C and paste :)
You will get:
Column C
1
2
0

Sum of multiple columns if they match

I have this table of data:
A B C D E
003B1016 1 003G1016 1 003B1016
003G1015 1 003G1391 2 003G1015
003H0121 4 003H6208 2 003H0121
003H6209 1 003H6209 1 003H6209
I want to sum B+D if A and C are identical , how would i do that?
I have another 32000 rows of data. :) Thanks for the help
Put this in cell E1 and copy down:
=IF(A1=C1,B1+D1,"")
This says - if A = C, then add B+D. Otherwise, return blank "".
EDIT for new requirements
In order to add all amounts from column B where column A matches the current row and from column D where column C matches that row, where the row in column A exists anywhere and the row in column C exists anywhere, do the following formula in E2 and drag down:
=IF(ISERROR(MATCH(A2,A$1:A1)),IF(ISERROR(MATCH(A2,C:C,0)),"",SUMIFS(B:B,A:A,A2)+SUMIFS(D:D,C:C,A2)),"")
This says: look above the current row in column A - have we seen this item before? If no, continue with the formula. If yes, ignore, to avoid double counting. Then, Look at all of column C - does the value in the current row of A occur anywhere in column C? If no, then don't add anything. If yes, Add all items from column B where column A matches the current row, and add all items from column D where column C matches the current row.

How to format rows to color group by like values in column 1

I have a worksheet that has information like this:
a
a
b
c
c
c
How do I format it so that all of the rows that have a value of a in the first column are one color, then all the rows that have a value of b in the first column are a different color, etc. ?
Edit not from OP to add clarification from comment:
Everything is already sorted alphabetically, and will stay that way, and I want multiple colors.
Create a helper column with a formula like this;
=MOD(IF(A3=A2,0,1)+B2,2)
In this example column A is the column of sorted values to be grouped by, and column B is the helper column. The formula is entered on row 3. Set the first row of the helper column to the value 0 and the others to the formula. This will result in alternating values in the helper column for each group, ie;
a 0
a 0
b 1
c 0
c 0
c 0
d 1
d 1
e 0
You can then set conditional formatting based on the column value. If the value is 1 then highlight the row; if it is 0 do not highlight it. Or use alternating colors or whatever. You can reference any of the articles on the web that describe how to conditional format the entire row based on the value in the column.
IF(A3=A2,0,1) compares the current row (3) and prior row (2) returning a 1 or 0.
MOD( [...] +B2,2) accomplishes the alternation between 0 and 1 when the grouping column value changes.
I think you need a helper column, say B seeded with 1 in row1, and =IF(A1=A2,B1,B1+1) in B2 and copied down to suit. Then formulae of the kind below should suit for conditional formatting:

Performing a find within a find EXCEL VBA

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)

Resources