# How to apply a formula or VBA to get a specific result in a row

#### maxrhino

##### New Member
Hi,

I have a excel spreadsheet that includes some dual numbers through a column like

 2-1 6-4 8-0 . . . and goes

<tbody>
</tbody>
My question is that how can I apply to get a specific result in next column. For example, if D3 2-1, then put a 1 into E3... Or if D3 2-2 (if two numbers are equal) put a T into E3... to make it simplier: If first number is bigger than the second one, put a Y into the next column, or second number is bigger than first one, then put a H... etc.... I need to apply the formula through all column, and have to point it again that, two numbers are in the same row, must not be separated, they are separated with a minus key.

### Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

#### dulitul

##### Board Regular
Try this
=IF(D3=2-1, E3=1, IF(D3=2-2, E3="T", IF(D3=2-3, E3="H", "")))

Last edited:

#### Jeffrey20

##### Board Regular
If the numbers are one-digit numbers then use:

=IF(LEFT(A1;1)>RIGHT(A1;1);"Y";IF(LEFT(A1;1)<right(a1;1);"h";if(left(a1;1)=right(a1;1);"t")))

If you don't know how many digits the numbers have use:

</right(a1;1);"h";if(left(a1;1)=right(a1;1);"t")))
=IF(LEFT(A9;FIND("-";A9)-1)>RIGHT(A9;LEN(A9)-FIND("-";A9));"Y";IF(LEFT(A9;FIND("-";A9)-1)<RIGHT(A9;LEN(A9)-FIND("-";A9));"H";IF(LEFT(A9;FIND("-";A9)-1)=RIGHT(A9;LEN(A9)-FIND("-";A9));"T")))

Last edited:

Last edited:

#### maxrhino

##### New Member
Thank you so much dulitul and Jeffrey20 for quick answers, however both formulas did not work, in fact I got error.

#### maxrhino

##### New Member
Image isn't displayed, Jef.

For some weird reason the forum cuts my formulas :S

Here they are in an image:

#### Jeffrey20

##### Board Regular
Yeah sorry, I thought BayImg accepted hotlinking, here it is

Last edited:

#### maxrhino

##### New Member
Thank you so much for all answers but Excel returns data value errors in any case.

#### maxrhino

##### New Member
Okay I managed to put the formula in a right way. Thank you so much Jeffrey, works like a charm and you made my day for this.

Replies
7
Views
287
Replies
2
Views
285
Replies
4
Views
168
Replies
1
Views
546
Replies
3
Views
143

1,195,936
Messages
6,012,394
Members
441,695
Latest member
MickRobertson

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back