I have a data like this in excel:
1 1
1 2
2 2
3 2
And I want the result to be displayed like this:
1
1
1
2
2
2
2
3
Its like a ascending sorting. If the number in columnA <= columnB, it will be display first, at the same time, columnB will have a empty cell or blank value.
I have looked for this for a while but no one has the problem like this.
I would prefer a formula rather than VBA code.
Please advise, thanks!
Edit: I hope this explanation will be easier to understand
Data (A1:B2) - Result (C1:D4). Each number in Data (A1:B2) is a result of complicated formula so I cannot change its position
A B C D
1 1 2 1
2 3 4 2
3 3
4 4
Honestly, if you want to avoid VBA, here's a manual process that would give you the results you want:
Color each column (ie. Column A Red and Column B Blue)
Place values of column B under column A
Sort & Filter by Sort Smallest to Largest
Copy the contents of column A to column B
Last for Column A Find and Replace all* with format Blue then do the same for column B only with format Red. (See below for more info on how to do that).
Following those steps isn't the most conventional, but it will give you the results you wanted without VBA.
*Find and Replace based on font color:
1. Press Ctrl-H
2. Click Options
3. Click Format > Font > then select your font color > OK
4. With the Find What blank with the font color and the Replace With blank click Replace All.
Related
Suppose I have a simple dataset in Excel:
Column 1 Column 2
A 1
B 1
C 2
D 4
E 5
F 9
Now I want to mark the whole row with green color, if the value in column 2 is larger than 3. I apply a conditional format with the formula =$B2>3 applied on range =$A$1:$B$7 and it does not work:
One line where the value is 2 is marked green and one where it is 9 is not marked.
Now I want to mark the row, however only, if the value in column 2 is between 3 and 6. I apply the formula =AND(3<$B2;$B2<6) to the same range and it does not work:
Nothing is marked green.
Where is my mistake?
Update:
I now also tried =AND(3<$B1;$B1<6), but still nothing is marked green?
Change =$B2>3 to =$B1>3 which should work for you.
Your formula start range and apply start range must be same. Otherwise CF will highlight different cells.
I want to write numbers in excel starting from 000001 till 999999
I have done like this =TEXT(A2,"000001") but i am not been able to generate series even though not able to separate this in different attributes
Further I want to distribute each number in each different cell for example like this
A B C D E F G
000001 0 0 0 0 0 1
000002 0 0 0 0 0 2
till
999999 9 9 9 9 9 9
Use following formuls to B1 cell and drag then right and down as needed.
=MID($A1,COLUMNS($A$1:A$1),1)
See the screenshot.
Here is a better way:
In cell A1, type 1.
Select A1 and from Home tab, choose Fill > Series (top-right).
Choose Columns; Linear; set Step Value to 1 and Stop Value to 999999 or whatever you want. Click OK.
Use AutoFill feature to fill up to the number you want.
Right-click column A header and choose Format Cells.
Choose Custom formatting and type 000000 in the custom format type textbox.
Click OK. Your cells will now show 000001, 000002, ... and so on.
In cell B1, type the following formula:
=INT(MOD($A1/(POWER(10, 7- COLUMN())), 10))
Copy B1 to columns C1 through G1.
Copy range B1:G1 to all subsequent rows B2:G999999 or whatever.
Notes
One advantage of this approach is that column A is numeric, not text, so you can enter any 6-digit (or less) integer in it directly from keyboard and the cells will update themselves correctly.
Column A will adjust number of leading zeros automatically for 6-digits or smaller numbers.
The formula simply divides the number in column A by 10, 100, 1000 and so on and then takes remainder by 10, to get the corresponding digit at that decimal place.
You can easily modify this formula to work with larger or smaller numbers. You simply need to replace 7 by (maximum number of digits in your number + 1).
Might be a bit easier with a VBA macro. Right-click the sheet tab, select View Code, paste the below code, and Run (F5)
Sub fill()
[a1:a999999] = "=text(row(), ""000000"")"
[b1:g999999] = "=mid($a1, column()-1, 1)"
End Sub
(Write this formula in Column A and extend it down to row 999999)
generating the series:
=RIGHT(10^6, 6-LEN(ROW(A1)))&ROW(A1)
Write this formula in Column B and extend it to Column G, then
extend the range of B1:G1 to B999999:G999999
Distributing digits
=MID($A1,COLUMN(A1),1)
I have 8 combinations o triplets, each with a name attached to them. For example:
Category a = 1,2,3
Category b = 3,1,2
etc...
Each value in the triplet is either 1, 2 or 3.
I need to be able to input 3 values (also 1,2 or 3) into 3 cells, and I need the corresponding category to be displayed next to them (based on the 8 hard coded variants).
For example: if I were to enter 3 1 2 into the three cells, "Category b" would show up in the 4th cell.
Here is a screenshot of what I need:
The yellow cells are hard coded.
I have a long list of green cells.
I need to calculate the category in the blue cells based on the green cells.
use this in E2:
=INDEX(G:G,AGGREGATE(15,6,ROW($G$2:$G$9)/(($H$2:$H$9=B2)*($I$2:$I$9=C2)*($J$2:$J$9=D2)),1))
Then copy down
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
I have a table in Excel. In each row, I want to highlight the columns that correspond to the maximum value in that row.
For example, if I have this table:
0 1 2 3
4 5 3 5
8 9 3 4
I want to highlight 3 in row 1, 5 in row 2 and 9 in row 3.
How can I do that automatically?
THANKS!
In Excel 2008, you can use Conditional Formatting in the Styles section of the Home Tab. Choose "Highlight Cells Rule", then "More Rules...". That opens the "New Formating Rule" dialog. Choose "Format only top or bottom ranked values". Then choose Format values that rank in the "Top" 1 and leave the % of selected range box UNchecked. Then click the Format button to pick the format that you want.
If you want to be able to do this fully automatically, what you can do is record a macro that does the actions described above and use that to repeat for all rows of your table.
I think you could do this with conditional formatting, and you wouldn't require code. Just create a formula that looks to see if the cell value is equal to MAX(range_name) and highlight the cell in whatever way you choose.
This is somewhat roundabout, but works for me. Add an extra column (E) somewhere, so you end up with this for data:
A B C D E
1 0 1 2 3 =MAXA(A1:D1)
2 4 5 3 5 =MAXA(A2:D2)
3 8 9 3 4 =MAXA(A3:D3)
Then in a cell, add a conditional format:
For A1: =IF(A1 = $E$1, 1, 0)
Use the format painter to copy this to the other cells in the row. Then copy to the column, modify each column so the $E$1 reference is corrected, and copy to those rose as well
Ugly, but gets the job done. Probably a quicker way to do it with VBA.