In Column A, it has ID and it is random.
Sometimes ID repeat 2 times, sometimes 10 times, it is different all the time.
I need to check if "MAN_ABC_COMMENT_CHANGE" doesn't occur.
If for example in image below for ID = 12345 in column D "MAN_ABC_COMMENT_CHANGE" never occurred, so in new sheet or somehow show that for id 12345 MAN_ABC_COMMENT_CHANGE never occurred.
I have over 5000 rows of data and over 1000 ID
One method...
1) set up a Pivot table of ID from the data
2) add a formula in B2 =countifs(Sheet2!A:A,A2,Sheet2!D:D,"MAN_ABC_COMMENT_CHANGE")
3) copy down (double click the bottom right of cell to autofill)
4) the rows with zero are the ones you want (can filter them as required)
Related
I am trying to lookup values from Table 1 to Table 2 based on Col1 in Table 1.
The catch is that Table 1 has duplicate values (for example, A is repeated 3 times) but I don't want to duplicate the returned value from Table 2.
How can this be done through either excel or sql (e.g. LEFT JOIN)?
What SQL are you using? Are you familiar with CTE and partition?
Have a look here: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/597b876e-eb00-4013-a613-97c377408668/rownumber-and-cte?forum=transactsql
and here: (answer and 2nd comment): Select the first instance of a record
You can use those ideas to create another field that tells you whether the row is the first, 2nd , 3rd etc occurrence of Col1. Eg you'd have something like
1 B Red 150
2 B Red 150
and you can then update col3 to be zero where this new field is not 1.
EDIT: since you asked about Excel: in Excel, sort by whatever criteria you may need (col 1 first, of course). Let's say that Col1 starts (excluding the heading) in cell C2. Set cell B2 =1. Then write this formula in cell B3:
=IF(C3=C2,B2+1,1)
and drag it all the way down. This will count the occurrences of col 1, ie it will tell you which is the first, 2nd etc time a given value appears in col1. You can then use it as as the basis to change the value in other columns.
Also, it is not good practice to have a column where the first cell has a different formula from the others. You can use the same formula nesting another IF and referencing the row, so as to set one formula for the first row and one for the others.
Have to create a column next to existing column. my present table is like this
and result needed is like this. Each date value is getting repeated 3 times and getting incremented by 1
Pick any cell and enter:
=DATE(2018,8,21+ROUNDUP(ROWS($1:1)/3,0))
and copy downward.
Here our start cell is one cell to the left of the 21.
Manually type in the first 3 into A1:A3 (or rows 1 to 3) in A4 (or row 4) reference A1 (row 1) and add 1 to it. Then drag the formula down.
The formula should look like =A1+1
I have been trying to write a for each loop to go through each row in in one sheet (sheet 2) to remove duplicates in another sheet (sheet 1). I have had no luck researching either.
In sheet 1, I have a list of customer numbers in column B with the type of product they purchased in column c and the cost of that product in column d. In another sheet 2, I have a list of customers in column a and list of products in column b.
I have been trying to write a for each loop to go through each row in sheet 2 to check the customer number and product, find all the duplicates in sheet 1 with the same customer number and product, and deleting the row with the higher balance.
Sheet 1
A(Year) B(Customer #) C(Product Type) D(Cost)
1) 2015 100 A 1
2) 2015 100 A 2
Sheet 2
A(Customer #) B(Product Type)
1) 100 A
For example, if sheet 2 had 100 in column a and A in column b, it would delete row 2.
You could try using the remove duplicates option within excel, would that solve your problem? Or is Sheet 2 update to remove certain customer orders that you would also like to remove.
Edit: To expand on this. Take the list, sort it by customer and cost (low to high). Then if you click remove duplicates, you'll have the option to select what columns to use as a basis for removing duplicates, so obviously remove cost, and then it'll clear out all but the topmost row, which as now been sorted to be the lowest value.
I am trying to figure out if there are any differences between a list of data with another. In order for a row of data to "match" with another row, the row must have the same values in their corresponding column. The rows themselves do not have to be in any particular order. In particular, I am dealing with a parts list, where there are part numbers, descriptions, etc. I am trying to figure out if any rows of data are different from rows of data from another list.
I found Compare two sheets using arrays, which may have the answer to my problem, but I am having trouble figuring out how to adapt to my code due to inexperience in Visual Basic.
I was able to get it to work for a single column of data, comparing one column of data from one sheet to another, but cannot get it to compare entire rows of data.
Here is an example of I want this to work:
Sheet 1 Sheet 2
Column 1 Column 2 Column 1 Column 2
Row 1 22a 33 11 11
Row 2 22a 33a 22a 33
Row 3 55 22b 55 23b
The code in the link will tell you what is not in sheet 1 but in sheet 2 and vice versa. In this example, I would like the code to tell me Sheet 1 Row 2 and Sheet 1 Row 3 are not in Sheet 2, and Sheet 2 Row 1 and Sheet 2 Row 3 are not in Sheet 1 (Sheet 1 Row 1 and Sheet 2 Row 2 match).
If that is ok by you, you can do it without VBA using the following formula:
={IF(IFERROR(MATCH(A1&"|"&B1;Sheet7!$A$1:$A$3&"|"&Sheet7!$B$1:$B$3;0);-1)=-1;"Unique";"")}
Assuming that each of your tables start in A1 (so that the tables with three entries span A1:B3), and entering this formula into C1 (and copying it down), press CTRL+SHIFT+ENTER when entering the formula to create an array formula, this will show the word "Unique" in column C if the pair in that row on that sheet is not in any of the row-pairs on sheet 2.
You can then use conditional formatting to highlight unique rows, filter on the tables to include only unique rows, or some other way of doing what you need.
NOTE 1: I have entered my numbers in Sheet6 and Sheet7 instead of 1 and 2. The formula written above goes into Sheet6.
NOTE 2: My language use ; instead of , as function separator, so if yours use , you need to change that.
NOTE 3: You will need to expand the ranges Sheet7!$A$1:$A$3 and Sheet7!$B$1:$B$3 if your set grows (this will happen automatically if new rows are inserted in between the old ones). The best is still probably to create named ranges for each of the 4 columns, exchange the references with those, and manage the named ranges instead of the formulas.
NOTE 4: If your data set contains the character "|", you need to change that as well, to match some character that you for sure do not have there.
Alternatively you could in column C on each cheet enter (assuming first entry in C1)
=A1&"|"&B1"
and copy this down, then run the solution from your copied example using that C column instead of on A1 and B1.
I am a beginner in vba...i am doing a task which consist of 6 sequences..
Sequence 1
Sequence 2
Sequence 3
Sequence 4
Sequence 5
Sequence 6
In sheet-1 i have done all the calculations for all 6 sequences and tabulated the results..
The order of sequence changes according to constraints...i.e, "1,2,3","1,2,4","1,3,4","1,3,5"..)...
Is it possible to pick the required sequence along with its contents(tabulated results) from sheet-1 and display it in another sheet?
(i.e., For sequence order "1,2,4",only sequences 1,2 and 4 from sheet 1 should be displayed in another sheet)
Kindly help me to solve my problem..
I would like to add more data..
In Sheet 1 i have created a table which gives the order of sequence to be followed
Input data
Enter A
Enter B
Enter C (True or False)
Constraints
If (AND(A=B,C="TRUE"),"1,2,3",IF(AND(A<>B,C="TRUE"),"1,2,4",IF(AND(A=B,C="FALSE"),"1,3,4",IF(AND((A<>B,C="FALSE"),"1,3,5",""))))
RESULT DISPLAYED
1,2,3 OR 1,2,4 OR 1,3,4 OR 1,3,5 (DEPENDING ON MY INPUT DATA)
IN SHEET 2 I HAVE DONE THE CALCULATIONS FOR ALL THE SIX SEQUENCES
SEQUENCE 1
A) VERIFICATION OF X
B) VERIFICATION OF Y
C) VERIFICATION OF Z
SEQUENCE 2
A) VERIFICATION OF P
B) VERIFICATION OF Q
C) VERIFICATION OF R
.
.
.
.
TILL SEQUENCE 6
NOW, i want to filter my sequence according to the result displayed in sheet 1
example: If the sequence displayed in sheet 1 is 1,3,4 either only these sequences should be displayed in sheet 2 or the sequences 1,3,4 selected from sheet 2 shuold be displayed in sheet 3...
I am assuming that each sequence is a formula that produces a number (if not, post some sample data). Also assuming that the number is the order you want things displayed. Assuming sample data like this in Range("A1:A4):
=D1+D2
=D3+D4
=E4+E4
=F4+F5
Values like this in Range("A1:A4"):
5
4
1
2
So the order you want is A3, A4, A2, A1. Here is the VBA code:
'Copy the data so that we can maintain the original (optional)
For i = 1 to 4
ActiveSheet.Range("B1").Offset(i-1,0).Value = ActiveSheet.Range("A1").Offset(i-1,0).Value
next i
'Sort the new data
ActiveSheet.Columns("B").Sort key1:=Range("B1"), _
order1:=xlAscending, header:=xlNo
'Copy the new sorted rows to another worksheet
For i = 1 to 4
Sheets("Sheet1").Range("A1").Offset(i-1,0).Value = ActiveSheet.Range("B1").Offset(i-1,0).Value
next i
I made a lot of assumptions, so not sure if I got it right. Posting sample data makes it easier to answer.