I have a large list of users with various codes. The goal is to separate the good from the bad. All codes that start with P, H or F are good. All codes that start with L or K are bad. Example:
Email | Code 01 | Code 02 | Code 03 | Code 04 | RESULT
user01#gmail.com | PJR-VRF | | | | GOOD
user01#gmail.com | | LNR-JNT | | LNR-JNT | BAD
user01#gmail.com | | HVB-YWQ | HVB-YWQ | HVB-YWQ | GOOD
user01#gmail.com | | LNR-JNT | | KVB-MMO | BAD
user02#gmail.com | | | | PHH-KLP | GOOD
user02#gmail.com | | HNR-OPT | | LNR-JNT | GOOD
user02#gmail.com | | FLT-MWQ | | FLT-MWQ | GOOD
user02#gmail.com | | KVB-MMO | KVB-MMO | KVB-MMO | BAD
In other words, if a range contains any cells that begin with P, H, or F then good, otherwise bad. I've tried to use the following formula in the result column:
=IF(COUNTIF(B2:E2,{"H*","P*","F*"}),"good","bad")
It didn't work unfortunately, so I tried this:
=IF(COUNTIF(B2:E2,"H*") + COUNTIF(B2:E2,"P*") + COUNTIF(B2:E2,"F*"),"good","bad")
This seems to work, but is this the best method? Say I have 20 other conditions to check against? And need to add a third result? What is the best approach to sift this data?
You can use an array formula similar to this:
=IF(SUM((--($B2:$D2<>""))*(--ISNUMBER(FIND(LEFT($B2:$D2,1),"HPF"))))>0,"GOOD","BAD")
Please remember to press Ctrl+Shift+Enter to complete the array formula correctly.
If you need to add a third result:
=IF(SUM((--($B2:$D2<>""))*(--ISNUMBER(FIND(LEFT($B2:$D2,1),"HPF"))))>0,"GOOD",IF(SUM((--($B2:$D2<>""))*(--ISNUMBER(FIND(LEFT($B2:$D2,1),"EKD"))))>0,"OTHER","BAD"))
Related
I have two sheets inside Excel like this:
*Sheet 1*
| 20 | | |
|----|---|---|
| 21 | | |
| 22 | | |
| 23 | | |
*Sheet 2*
| Referenz | |
|----------|---|
| 21 | |
| | |
| 22 | |
| | |
| 23 | |
I would like the output in sheet 2 as shown. Now I tried leaving space between the cells by dragging it down, but it doesn't work as expected. I also had a look at INDEX but it is not what I'm looking for.
Can you please help me?
Assuming your data is in cells A2:A4 on the first sheet and you want the output on second sheet starting from second row, you can try following formula in sheet 2 row 2:
=IF(ISEVEN(ROW()),INDEX(Sheet1!$A$2:$A$4,CEILING(ROW()/2,1)),"")
Edit:
If I have understood what you need correctly then you can use a formula like
=Sheet1!A2&CHAR(10)
Copy down...!
Try this:
=IF(ISEVEN(ROW());A2+1;"")
Should give you the following result:
In case you want the rows that are uneven, just switch the "value_if_true" and "value_if_false" of the IF() formula.
Alright, I'm back. This time I'm trying to quickly select all of the values in a range which match values in a separate list, my first iteration will be to clear the contents of voided IDs, my second iteration will be to select those values and then replace them with corresponding new values.
I asked another question about VBA and was pointed in mentioning that I've tried to teach myself and find resources to work through these issues before but people seem to get pissed that I'm asking, if you could at least direct me to somewhere that I can learn about these matters (or even a place I can learn basic logic and have a list of usable functions without having to go through all the "How to make your first Excel VBA for some problem that nobody cares about" I would appreciate it)
Anyway I tried to watch a few videos and then hack together something but it seems pretty clear that the function they were using cannot be adapted for other uses. This is what I have at the moment:
Sub FilterElim()
finalRow = Range("g2").End(xlDown).Row
Range("A1").ClearContents _
Action:= xlClearContents, _
CriteriaRange: Range("Sheet4!B1:B10"), _
Unique:= False
End Sub
So based on some helpful questions I am making an edit to include an example and desired end
Example set:
Desired end result:
I presume I may need to perform a selection of some sort based on the Criteria before the ClearContents but I wasn't finding anything helpful on how to go about that. PLEASE and thank you.
| Contractor ID | Cont Name | Proj 1 | Proj 2 | Proj 3 | | | Old ID | Reconciliation |
|-----------------|-------------------|--------|--------|--------|---|---|--------|----------------|
| C1001 | Boba Fet | P1120 | | | | | P1001 | Void |
| C1003 | Jules Winnfield | P1031 | P1045 | | | | P1002 | P1010 |
| C1002 | Dom Cobb | P1001 | | | | | P1005 | Void |
| C1010 | Patrick Verona | P1020 | P1224 | P1251 | | | P1020 | Void |
| C1007 | Matt Damon | P1008 | P1005 | P1300 | | | P1045 | P1100 |
| C1004 | Ned Plimpton | P1002 | | | | | P1224 | P1300 |
| C1020 | Derek Zoolander | P1020 | P1290 | | | | | |
| C1009 | Charles Marlow | P1002 | P0090 | | | | | |
| C1011 | Robert Jordan | P1119 | | | | | | |
| C1015 | Perrin Aybara | P1200 | P1224 | | | | | |
| C1005 | Fuzzy Dunlop | P1005 | | | | | | |
| C1008 | Thomas A Anderson | P1001 | P1000 | | | | | |
| | | | | | | | | |
What makes you go for a VBA solution ?
Hard to do much without a glance of you data and expected result.
Non VBA option:
=IFERROR(INDEX($G$2:$G$15,MATCH(A32,$F$2:$F$15,0)),B32)
For a VBA option, you can try:
Option Explicit
Sub update_id()
Dim D1 As Object: Set D1 = CreateObject("scripting.dictionary")
Dim R1 As Range: Set R1 = Range("A2:A32")
Dim R2 As Range: Set R2 = Range("E2:E15")
Dim Rtmp As Range
For Each Rtmp In R2
D1(Rtmp.Value) = Rtmp.Offset(0, 1).Value
Next Rtmp
For Each Rtmp In R1
If D1.exists(Rtmp.Value) Then Rtmp.Offset(0, 1) = D1(Rtmp.Value)
Next Rtmp
End Sub
Working on the following set up :
Again, without a better understanding of your data and your issue, its hard to be more precise.
Consider the following data below:
| 1st | 2nd | A | B | C | D | E | F | G | H |
|-----|-----|---|---|---|---|---|---|---|---|
| y | x | | | 1 | | | | | |
| y | x | | | 1 | | | | | |
| y | x | | | | 1 | | | | |
| | x | 1 | | | | | | | |
| y | | 1 | 1 | 1 | | | | | |
| y | x | | | | | | 1 | | |
| y | | | | | | | | 1 | |
| | x | | | | | 1 | | | |
| | x | | | | | | | | 1 |
| y | x | | | | | | | | 1 |
What I wish to do is to return all column headers (from A to H) that meets the following condition: it should have a value of 1 that is both aligned with a y and x value from the first two columns.
I already have a working array formula to do this, which is as follows:
{=INDEX($C$1:$J$1,SMALL(IF(($A$2:$A$11="y")*($B$2:$B$11="x")*($C$2:$J$11=1),COLUMN($C$1:$J$1)-COLUMN($B$1)),ROW(1:1)))}
However, while I drag this down, it returns two C values and one for D, F and H.
This is since there are two 1's under header C that meets the said condition. What I want is to return unique values, so C should only be returned once. I tried to make use of MATCH and additional COUNTIF instead of the SMALL function, but it is returning an error, and the 'Evaluate formula' feature of Excel isn't helping. Below if the erroneous formula I experimented with:
{=INDEX($C$1:$J$1,MATCH(0,IF(($A$2:$A$11="y")*($B$2:$B$11="x")*($C$2:$J$11=1),COUNTIF($N$1:N1,COLUMN($C$1:$J$1)-COLUMN($B$1))),0))}
A workaround I am currently doing is to make my first formula a "helper column" and then create another formula based from the first formula's result to return only the unique values. However, the double array formula is heavily affecting the efficiency of Excel's calculation due to the huge volume of data I'm dealing with.
Any help/suggestions will do please (no VBA please, since I believe it's not needed here). Thanks!
Insert a helper row. I did it just under your header row before your data. In this row you check to see if there is a 1 that lines up with an x and a y. I assumed this to be non blank, but if its specific values change the formula from <>"" to ="y" or =134 as the case may be. Place the following formula under your first column header you are interested in and copy right.
=--(0<SUMPRODUCT(($B$3:$B$12<>"")*($C$3:$C$12<>"")*(D3:D12=1)))
Then where you want to generate your list in a column without space and sorted in the order the appear in from left to right in the headings, use the following formula and copy down as required:
=IFERROR(INDEX($1:$1,AGGREGATE(15,6,COLUMN($D$2:$K$2)/$D$2:$K$2,ROW(A1))),"")
The above formula put in a blank value when no column heading applies are you have copied the formula down beyond the number of applicable columns.
The above formulas are based on the proof of concept image below. Adjust ranges to suit your needs.
Have you tried without the use of an array formula? I don't know how large the data actually is. But, this might be what you are looking for:
=IF(COUNTIFS($A:$A,"y",$B:$B,"x",C:C,1)>0,C1,"")
Assuming column A is "1st" and "H" is your last column at colunm J. Try pasting the formula at "K1" and drag it to your right until "S1".
I'm relatively new to VBA coding and wanted to get some ideas as to how I could do some data cleanup/reformatting. I have a excel data export from a system that has very little business logic/validation.
As a result I have a Date column that has data integrity issues that I have examples of below. Dates are not formatted the same consistently, there is dates combined with text strings, in some cases only text (in the date field)
Here are examples of the data I have in the Date column:
2/2/2018
8/3/2018
1996
1990-1991
02/29/95
1992-93
05/08/200
DECLINED
5/1418
8/14/2018
06/09/200
1/12/94, DECLINED CONTRACT 12/01/00
EXP CAT I
06/14/23018
1996
5-1-1207/07/92
8/3/2018
3-10-
1996
02/27/187
1-29-14
2/2/2018
1-4-11
3.8.99
2-17-12
10-6-16
I would like to convert the dates into the MM/DD/YYYY format. I realize where I just have pure text (e.g. 'DECLINED') that there is no way to extract a date, however I'm hoping for the other examples it may be possible to format the date to the above.
Some of the dates are plain no good (e.g. '5/1418' can't determine how to translate this), but I'm hoping for at least the dates formatted with MM-DD-YYYY and MM.DD.YYYY and similar combinations there is a way to convert their formatting, as well as where I just have 1 digit Month and Day (e.g. 2/2/2018 should be 02/02/2018). If just a 4 digit year is provided I want to convert to '01/01/(year)' Any ideas are appreciated.
This is one of those problems that you could spend a year trying to solve to get a 100% solution. The good news is you can get super lazy and have a nice 60% solution by using the VBA CDATE() function which makes a good guess for whatever you feed it. Tossing Split() at it to peel off extra words and whatnot (that may follow the date with a space or a comma) you can get most of the actual dates covered here. The remaining records are either dates that are so badly formatted that you will have to write code for the edge case, or it's just garbage non-date stuff you can ignore.
Create a new module in VBA and pop this in:
Public Function dateguesser(inDate As String) As Date
dateguesser = CDate(Split(Split(inDate, " ")(0), ",")(0))
End Function
Then in your sheet you can use this as a new function
=dateguesser(A1)
And copy down. For your list, you get the following:
+----+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| | A | B |
+----+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 1 | 2/2/2018 | 2/2/2018 |
| 2 | 8/3/2018 | 8/3/2018 |
| 3 | 1996 | 6/18/1905 |
| 4 | 1990-1991 | #VALUE! |
| 5 | 02/29/95 | #VALUE! |
| 6 | 1992-93 | #VALUE! |
| 7 | 05/08/200 | ############################################################################################################################################################################################################################################################### |
| 8 | DECLINED | #VALUE! |
| 9 | 5/1418 | ############################################################################################################################################################################################################################################################### |
| 10 | 8/14/2018 | 8/14/2018 |
| 11 | 06/09/200 | ############################################################################################################################################################################################################################################################### |
| 12 | 1/12/94, DECLINED CONTRACT 12/01/00 | 1/12/1994 |
| 13 | EXP CAT I | #VALUE! |
| 14 | 06/14/23018 | #VALUE! |
| 15 | 1996 | 6/18/1905 |
| 16 | 5-1-1207/07/92 | #VALUE! |
| 17 | 8/3/2018 | 8/3/2018 |
| 18 | 3-10- | #VALUE! |
| 19 | 1996 | 6/18/1905 |
| 20 | 02/27/187 | ############################################################################################################################################################################################################################################################### |
| 21 | 1-29-14 | 1/29/2014 |
| 22 | 2/2/2018 | 2/2/2018 |
| 23 | 1-4-11 | 1/4/2011 |
| 24 | 3.8.99 | #VALUE! |
| 25 | 2-17-12 | 2/17/2012 |
| 26 | 10-6-16 | 10/6/2016 |
+----+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Clearly this is just a starting point, but I think it's a good solid starting point. The remaining crap you can start writing edge cases for in your VBA, but the closer you get to 100% the longer it's going to take to get any further and before you know it you'll be a month into this and wondering what's happened to your life.
Program: Excel 2010
Requirements: Prefer no VBA (Macro free book)
I am creating a spreadsheet to calculate items required for components (parts). I have a list of the product, and under the number of specific parts. I have a calculation which tells me what the total parts are needed, but, is there a better way?
=($C$32*C34)+($D$32*D34)+($E$32*E34)+($F$32*F34)+($G$32*G34)+($H$32*H34)+($I$32*I34)+($J$32*J34)+($K$32*K34)
| A | B | C | D | E | F |
| Making: | | 2 | 2 | 2 | |
|---------------|-------|------------|-------------|-----------------|---------|
| Item -> | Total | Small raft | Rowing boat | Sm sailing boat | Corbita |
| | | | | | |
| Planks | 20 | 4 | 6 | | |
| Logs | 8 | 4 | | | |
| Nails - Large | 16 | 8 | | | |
| Oars | | | | | |
In the above, you can see that ($C$32*C34) = 8 & ($D$32*D34) = 12 => 12+8 = 20 (B34) (Planks Total)
Is there an easier way of doing this, or will my equation just keep getting bigger?
Thanks in advance.
As chris neilsen mentioned in his comment, you can use the SUMPRODUCT function in Excel. The formula in your cell B34 (total planks) should look like this:
=SUMPRODUCT(C32:K32,C34:K34)
This has the effect of multiplying the corresponding components in the given ranges (C32 * C34, D32 * D34, etc.) and then returning the sum of those products/multiplications.
As you add more columns, you can expand K to the last column in the range that you want to add up in both ranges.