Changing Cell Reference in Formula

J

JimS

Excel 2007

I've got this big long formula:

=IF(AND(CODE(RIGHT(A2,1))>=188,CODE(RIGHT(A2,1))<=190),1*LEFT(A2,LEN(A2)-1)
+(CODE(RIGHT(A2,1))-187)/4,A2)-IF(AND(CODE(RIGHT(B2,1))>=188,CODE(RIGHT(B2,1))<=190),1*LEFT(B2,LEN(B2)-1)
+(CODE(RIGHT(B2,1))-187)/4,B2)

What I want to do is go through and change all of the A2 to k16, and
change all of the b2 to k15.

What is the easiest way to do that?
 
D

Dave Peterson

Select at least two cells (click on this cell, and ctrl-click on an empty cell)

Then use a couple of Edit|Replace's.
 
R

Rick Rothstein \(MVP - VB\)

If, as I suspect, the only non-digits that would appear in A2 and B2 are the
fractional symbols with ASCII/ANSI codes of 188, 189 or 190, then you can
use this much shorter formula to do what your posted formula does...

=IF(ISNUMBER(A2),A2,LEFT(A2,LEN(A2)-1)+(CODE(RIGHT(A2))-187)/4)-IF(ISNUMBER(B2),B2,LEFT(B2,LEN(B2)-1)+(CODE(RIGHT(B2))-187)/4)

Of course this suffers from repeated use of the A2 and B2 references. The
following formula, while longer than the above formula but still much
shorter than yours, has the benefit that the A2 and B2 references are used
only once each...

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,CHAR(188),".25"),CHAR(189),".50"),CHAR(190),".75")-SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B2,CHAR(188),".25"),CHAR(189),".5"),CHAR(190),".75")

Rick
 
J

JimS

This is beautiful (the second one particularly).

This also clears up a VALUE error I was getting if my selected number
was less than 1, such as 1/2, 3/4, etc.

Very nice. Thanks so much.
 
R

Rick Rothstein \(MVP - VB\)

You are quite welcome... I am glad you found the formulas useful. In case
you were wondering why I worded my response to you in the way I did, I only
just a couple of minutes ago saw your earlier thread where the formula you
posted in this thread was derived at. Once I worked out what you were
attempting to do with that formula, I then decided it looked too long. My
first solution was actually the SUBSTITUTE function one, but that looked too
long to me also, so I kept at it until I came up with the IF function
version. Being that I wasn't 100% sure what you were asking for in this
thread, I decided to post both formulas for your consideration.

Rick
 
P

Pete_UK

Hi Jim,

another approach would be to put the original formula in C2, looking
at A2 and B2, in a new worksheet. Then <cut>/paste the formula into
the cell where you want it to appear in your final sheet. Then cut/
paste cell A2 to K16, and cut/paste cell B2 to K15, and the formula
will have adjusted itself - you can now copy the formula into your
destination sheet.

Hope this helps.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top