Simple excel adding two cells and displaying alphabetically - excel

This seems like an incredibly simple problem but I can not figure out how to solve it.
I am trying create a new column with pair of place names in from an excel sheet, a simplified version of which is shown below.
Sheet 1:
| A
1 Dunfermline
2 Torryburn
3 Burntisland
4 Kinghorn
5 Torryburn
6 Carnock
I would like to pull out into B1, B3, B5 et. the pairs of places. I have managed to do this using
=A2 & "-" & A3
but I would like the place name that begins with the letter earliest in the alphabet to be displayed first, as below. My method does not work in the case of B5 - I can only return 'Torryburn - Carnock'
Desired Output:
| A | B
1 Dunfermline Dunfermline - Torryburn
2 Torryburn
3 Burntisland Burntisland - Kinghorn
4 Kinghorn
5 Torryburn Carnock - Torryburn
6 Carnock
Is there a method of sorting the cells and adding them together as required?

<> does the trick:
=IF(A2<A3,A2,A3) & "-" & IF(A2>A3,A2,A3)

You can always use the IF function (or IIF, depending on your version of Excel) to check if A2 < A3, and then show the appropriate reuslts. For example:
=IF(A2 < A3, A2 & "-" & A3, A3 & "-" & A2)

Related

Excel: Frequency of variables using countif with &

I have two excel sheets. I am finding the frequency of variable school IDs from sheet 1 into sheet2. Lets say a student volunteers for some activity at two schools. So there is an &. I want countif to count schools even where there is &
sheet1
A B
1 Student name School ID
2 S1 Sch333 & Sch209
3 S2 Sch209
4 S3 Sch333
5 S4 Sch209 & Sch111
6 S5 Sch209
sheet2
A B
1 School ID Frequency
2 Sch209
3 Sch333
4 Sch111
Formula for frequency of school IDs in cell B2 of sheet2
=COUNTIFS('sheet1'!$b:$b,'sheet2'!a2)
This ignores the rows where there is &. Expected output
A B
1 School ID Frequency
2 Sch209 4
3 Sch333 2
4 Sch111 1
You can sum the counts for the value alone plus before or after " & "
Maybe,
In sheet2, B2 array (CSE) formula copied down :
=COUNT(SEARCH(A2,'sheet1'!$B$2:$B$100))
Remark : Array (CSE) formula to be confirmed by "Ctrl"+"Shift"+"Enter" to enter it.
According to #shrivallabha.redij, you can remplace your formula
=COUNTIFS('sheet1'!$b:$b,'sheet2'!a2)
by this one:
=COUNTIFS('sheet1'!$b:$b,"*" & 'Sheet2'!a2 & "*")

How can I merge two columns with data where if one column's cell is empty the adjacent cell is full?

Basically like this:
ab
0
1
5
9
V
a
0
1
5
9
How can I quickly merge columns a and b in this way in libreoffice calc?
In Excel:
in V1 enter:
=A1 & B1
and copy downward.

copy cell contents E1 to E2 if C1=C2 Excel vba

I have a monster spreadsheet that has codevalues in column C and display values in column E. Each display value is only shown once per code value and i need it in every row.
is it possible using VBA to copy the cell contents of E2 to E3 if C2 = C3 as in to update the blank to the correct value?
so if C2=C3 then copy B2 to B3???
heres a subset of the 32000 rows i need to cross check against another domain
C (code value) E(display)
2 83732063 Red Cell Ferritin-SCH
3 83732063
4 83732067 Plasma Volume-SCH
5 83732071 Acylcarnitine Level-SCH
6 83732071
7 83732075 Carnitine Total Level-SCH
8 83732075
9 83732079 Creatine Level-SCH
10 83732083 Gamma Aminobutyrate Lvl (CSF/Urine)-SCH
Try,
on error resume next
with worksheets("sheet1").columns("E")
with .specialcells(xlcelltypeblanks)
.formular1c1 = "=if(rc[-2]=r[-1]c[-2], r[-1]c, text(,))"
end with
.value = .value
end with
on error goto 0

Excel how to find values in 1 column exist in the range of values in another (approximate)

How can I search if values in one cell (column A) exist in column B. With an approximate threshhold of +/- .5
For instance:
Cell A2: 100.26
Column B: 100.30
Is there a formula that can search A2 within all of column B for an approximate match +/- .5 to return true/false?
You can use COUNTIFS() for this:
=COUNTIFS(B:B, "<" & A2 + 0.5,B:B, ">" & A2 - 0.5)
This tests values in Column B twice. Once to see if there is a value less then A2+.5 and then again to see if that value is also greater than A2 - .5
If you want this to return True/False, just turn it into an inequality:
=COUNTIFS(B:B, "<" & A2 + 0.5,B:B, ">" & A2 - 0.5)>0
Update with Example
To show this working, put value 10 in cell A2. Then in B1 though B5 put the following list:
1
4
10.2
20
24
Now in C1 (or any cell on the same tab that isn't A2 or in Column B) put the formula from above:
=COUNTIFS(B:B, "<" & A2 + 0.5,B:B, ">" & A2 - 0.5)>0
And it will spit out "True" because the value 10 that is in cell A2 is within +/-5 from a value that exists in Column B.
Add 2 helper columns C and D where C is =B1-0.5 and fill down and D is =B1+0.5 and filled down.
Then =if(and(a2>C2,a2<D2,TRUE,FALSE)

Microsoft Excel 2010: Help making a Formula to up Values by a repeating pattern

I have a Spreadsheet, and inside this sheet contains a column with numbers, I want to make a formula that will go down that Column and do basically this.. Values: 1 will be 9.50. 2 will be 9.75. 3 will be 10.00. Ect going up to Value of 100? Is that possible for a Formula? I keep playing with it but can't really seem to get it down. Any help would be appreciated.
Column A: 1
1
1
1
1
2
2
2
2
2
2
2
2
2
3
3
3
3
There is not a set amount to how many values are in there.
this should do it supposing that column A has these values 1, 2 ...etc that your computing will be based on
=MIN(9.25+A1*0.25;100)*COUNT(A1)
In A2, enter the formula
=A1 + (9.5-A1)
then in the cell just below it (A3), enter
=A2+0.25
Assuming A1 is the top left. Copy the formula in A3, select the next 399 cells and paste. Then select A2 - A364 and copy. Then select B2 -xx364 and paste. xx is the last column with data. If you want, set the height of your first column to 0 to hide it.
=(A1-1)*0.25+9.5 where A1 contains any number you want

Resources