Convert some cells in a column from date format to text - excel

Given a column like this:
Column A
1 4
2 Blank
3 Blank
4 3
5 blank
6 2NDF
7 Blank
8 blank
9 1/2/2014 <-- Date value I need to change to a text value: "1-2"
10 blank
11 5/1/2014 <-- Date value I need to change to a text value: "5-1"
12 blank
...
I need to find a way to programmatically change each cell that contains a date value like in rows 9 and 11 into a text value the equivalent of the numeric month followed by a dash follwed by a numeric day. I have 24,000 rows. Doing a find and replace is not practical. I cannot change the format of the entire column because rows like 1 and 4 get converted and I don't want those to get converted.

Create a new column B and use the function
=IF(NOT(ISERROR(DATEVALUE(A1))),MONTH(DATEVALUE(A1))&"-"&DAY(DATEVALUE(A1)),A1)

OK, I achieved the result I wanted by splitting out three "if" tests (similar to what Brett suggested) into 3 additional columns. Each column had its separate "if" test and built on the column before it. Here are the if tests:
=IF(N5>40000,MONTH(N5)&"-"&DAY(N5),N5) # sets format I want and skip cells that are low integers and not dates
=IF(O5=0,"",O5) # Sets cells with "0" in them to blank
=IF(ISERROR(P5),N5,P5) # fixes cells that were originally text and that produced errors

Given that in the OP the data seems to be in ColumnA starting in Row1 a single formula such as:
=IF(OR(A1<40000,ISTEXT(A1)),A1,MONTH(A1)&"-"&DAY(A1))
and copied down would seem adequate.

Related

Move the value of all cells in a column to their corresponding excel row number

Let's say i have the below list of Whole numbers in Column A. If you observe the list of numbers, you will see that number "5" and 6 is missing.
A
3
2
4
1
7
8
what I want to achieve is to place (sort) the numbers on the column such that each cell value will take its position according to excel row numbering. which means:
I should have something like this
1
2
3
4
7
If it's as simple as stated, this should work.
In column B, say:
=IF(COUNTIF(A:A,ROW())>0,ROW(),"")
Note: It does not account for duplicates, or anything complicated really.
Further Note: To clarify, all this does is check if the row that the formula is in, is in column A. If it is, then it returns the current row.

Excel mapping and create a new column

Excel file columns:
A B C
2 two 3
5 five 8
3 three 10
8 eight 11
12 one 15
I want to create a new column Din same file like below:
A B C D
2 two 3 three
5 five 8 eight
3 three 10
8 eight 11
12 one 15
I want to map C and A and if there's a match D takes values of B.
Example: Value 3 in C is present in A, so D will take corresponding B value three.
Thanks!
So building on BigBen's additional suggestion of using an IFERROR, I believe you want something akin to this in Column D:
=IFERROR(VLOOKUP(C1, A:B, 2, FALSE), "")
... and then drag down the formula throughout Column D
Now, there are some assumptions being made here:
Your data does not have any header row, ala the data starts in Row 1, not Row 2
You want empty/blank values where there is no exact match (this is BigBen's IFERROR suggestion). Your current question layout seems to suggest this. Otherwise, you'll get #N/A in all those blank cells in Column D.
EDIT: To confirm, I used your data (though I started in Row 2), and here's how it looked after -
If one has DA-functionality you could use:
1) - Excluding empty cells using FILTER:
Formula in D1:
=FILTER(B1:B5,COUNTIF(C1:C5,A1:A5)>0)
2) - Including empty cells using XLOOKUP:
Formula in D1:
=XLOOKUP(C1:C5,A1:A5,B1:B5,"")
If one does not have access to DA-functionality you could use:
1) - Excluding empty cells using INDEX, MATCH and SMALL:
=IFERROR(INDEX(B$1:B$5,SMALL(IFNA(MATCH(C$1:C$5,A$1:A$5,0),""),ROW(A1))),"")
Note 1 - This needs to be array entered through CtrlShiftEnter
Note 2 - Alternatively, one could use a non-array entered approach including AGGREGATE as per #basic: =IFERROR(INDEX(B$1:B$5,AGGREGATE(15,6,MATCH(C$1:C$5,A$1:A$5,0),ROW(A1))),"")
2) - Including empty cells using VLOOKUP:
Please refer to the other answer given by #Gravity here.
Basically the difference between both approaches could be vizualised like:

Count the number of columns with nonblank cells excel formula

I'm trying to count the number of columns that contain some text. So for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
x x x
xxxxxx xxx
xxxxxxxxxxxxxxxxxxxxxxxxx
Something like that should return "13". Doesn't matter how many cells contain text in the column, all I care about is how many columns contain text. Any suggestions?
While this isn't sophisticated coding or anything, this has worked well for me in the past.
At the top of each column (above the header, somewhere not in the way and that you won't need to use) add a CountA() formula that tells you how many cells in that column are not empty.
Put that inside an IF statement. =If(CountA("YourColumnRange") > 0, 1, 0)
Then, where ever you need it, sum up the results of each of the formulas for those columns and that will give you the total number of columns you are looking for.
If you don't want to display the "1" or "0" at the top of each column, simply change the text color in those cells to match your background (default being to change the text color to white).
Let me know if any of that needs clarification.

Split multiple values in a column into separate columns

My source table looks like this:
A1 12
A2 13
B1 14
B2 15
B3 16
I want it in a format like below:
1 2 3
A 12 13
B 14 15 16
Since there is large amount of data, it can't be done manually.
Please let me know how to do this?
I can't quite see how you want it formatted as the question isn't formatted.
However, you can use a feature in Excel called Text to Columns, on the Data tab.
This allows you to split text in a single column into multiple columns. You can specify the delimiter (the character to divide the columns), which may be a space or tab in your case.
Create a third column with formula =LEFT(A1, 1). Then a fourth column with =MID(A1,2,100). Insert a new Row 1 and give each column a name. Finally, insert a Pivot Table with column 3 as the row headers and column 4 as the column headers.
Another option might be to combine elements of the two existing answers. Insert a new ColumnB, split ColumnA with Text to Columns, Fixed width (one character), add labels (say a, b and c) to the columns then pivot with a for ROWS, b for COLUMNS and c for VALUES.

Consolidate two or more columns of data into one column using formula

I need to collect Sch Code from different columns into one column as shown below.
First priority is by formula or UDF Function if possible.
My Data:
Column A Column B Column C Column D Column E Column F Column G
SCH Code Value SCH Code Value Rating SCH Code Value
C01-3-1 4 C01-4-1 8 300 C02-3-1 8
300 C02-3-5 9
C01-3-2 5 C01-4-2 12 300 C02-3-2 12
C01-3-3 6 C01-4-3 21 300 C02-3-3 21
300 C02-3-6 10
C01-3-4 7 C01-4-4 4 300 C02-3-4 4
Required Result (Only Sch Code required in summary sheet but it is required by formula or VBA UDF function) :
Column A
C01-3-1
C01-3-2
C01-3-3
C01-3-4
C01-4-1
C01-4-2
C01-4-3
C01-4-4
C02-3-1
C02-3-5
C02-3-2
C02-3-3
C02-3-6
C02-3-4
You can collect unique non-blank values from column A with an array formula e.g. =INDEX($A$2:$A$99,MATCH(0, IF(LEN($A$2:$A$99),COUNTIF(I$1:I1,$A$2:$A$99),1),0)). Since this returns #N/A where it has no more values to return from its column, you can pass control over to a similar formula that references another column with IFERROR.
    
To choose from your three columns of SCH Codes, you would need to stack this 3 deep. The formula in I2 is:
=IF(LEN(I1),IFERROR(INDEX($A$2:$A$99,MATCH(0, IF(LEN($A$2:$A$99),COUNTIF(I$1:I1,$A$2:$A$99),1),0)),IFERROR(INDEX($C$2:$C$99,MATCH(0, IF(LEN($C$2:$C$99),COUNTIF(I$1:I1,$C$2:$C$99),1),0)),IFERROR(INDEX($F$2:$F$99,MATCH(0, IF(LEN($F$2:$F$99),COUNTIF(I$1:I1,$F$2:$F$99),1),0)),""))),"")
This array formula requires Ctrl+Shift+Enter, not just Enter. Once entered correctly, it can be filled down to catch all possible values. I would fill down for at least three times as many rows as you have in order that the blanks would have a place if they were filled in at a later date.
In theory, you could stack this much deeper but for practical purposes, I wouldn't go much deeper than this. Array formulas eat up calculation resources at a logarithmic rate so the size of your data is going to be a key factor on whether this is a suitable solution.
One solution:
Copy and paste all values in column C below column A data. Highlight column A and go to Data>Remove duplicates then Data>Sort.

Resources