Formula problem.

Spraggs

Well-known Member
Joined
Jan 19, 2007
Messages
704
Could someone please put me right with the formula I've attempted below.

=IF((C4=1)LEFT(A4,4),IF(C4=2)LEFT(A4,8),IF(C4=3)LEFT(A4,12),IF(C4=4)LEFT(A4,16),"")

Thanks Jase
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Is this what you mean?
Code:
=IF(C4=1,LEFT(A4,C4*4),IF(C4=2,LEFT(A4,C4*4),IF(C4=3,LEFT(A4,C4*4),IF(C4=4,LEFT(A4,C4*4),""))))
 
Upvote 0
I think you want this:

Code:
=IF(C4=1,LEFT(A4,4),IF(C4=2,LEFT(A4,8),IF(C4=3,LEFT(A4,12),IF(C4=4,LEFT(A4,16),""))))
 
Upvote 0
Sorry guys can I try again.

Cell A3 example ...
1234-ABC-DEF-HIJ-AB123

Cell C3 can be either 1,2,3,4 or 5

If cell C3 is 1 then return "" in D3
If cell C3 is 2 then return 1234 in D3
If cell C3 is 3 then return 1234-ABC in D3
If cell C3 is 4 then return 1234-ABC-DEF in D3
If cell C3 is 5 then return 1234-ABC-DEF-HIJ in D3

Thanks Jase
 
Upvote 0
Is it C3 or C4?
Change to fit:
Code:
=LEFT(A3,(INDEX(C3,{1,2,3,4,5})-1)*4)
 
Last edited:
Upvote 0
I've tried this but it returns exactly what's in column A.

If I have 1234-ABC-DEF in column A then I need 1234-ABC in D when 3 is in C.
 
Upvote 0
With the last formula I post, I have the following:

A1: 1234-ABC-DEF-HIJ-AB123
C3: 3

A2 has the formula:
Rich (BB code):
=LEFT(A1,(INDEX(C3,{1,2,3,4,5})-1)*4)
And my screen is showing me in cell A2, as output:
1234-ABC

You need to change the cell references to what you require, I can't see your sheet (because I'm not pyschic) so a little bit of tinkering on your part, may be required.
 
Upvote 0

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top