#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Bug?

am am trying to use the following code in a cell:

=LEFT(Sheet1!S1,2)&left(x,2-LEN(sheet1!S1))

it's designed to extract the first two characters from S1 on sheet1, but if
there are not two characters there, to use the first two from a cell named
'x'.
It works fine when the target cell starts with alphas, but fails if the
target cell has nemerics for the first 2 chacters. Appreciate any guidance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Bug?

Try this:

=IF(LEN(Sheet1!S1)=2,LEFT(Sheet1!S1,2),LEFT(x,2))

Mike

"General" wrote:

am am trying to use the following code in a cell:

=LEFT(Sheet1!S1,2)&left(x,2-LEN(sheet1!S1))

it's designed to extract the first two characters from S1 on sheet1, but if
there are not two characters there, to use the first two from a cell named
'x'.
It works fine when the target cell starts with alphas, but fails if the
target cell has nemerics for the first 2 chacters. Appreciate any guidance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Bug?

Not sure what "fails" means to you, but if S1 contains more than 2
characters, the second part of your formula will return a #VALUE! error,
since you can't take a negative number of characters with LEFT()\

Seems to me you could use

=LEFT(Sheet1!S1&x,2)



In article ,
General wrote:

am am trying to use the following code in a cell:

=LEFT(Sheet1!S1,2)&left(x,2-LEN(sheet1!S1))

it's designed to extract the first two characters from S1 on sheet1, but if
there are not two characters there, to use the first two from a cell named
'x'.
It works fine when the target cell starts with alphas, but fails if the
target cell has nemerics for the first 2 chacters. Appreciate any guidance.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"