Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35
Default Need help with If statement

Hello,

I need help with a nested if statement. How would I build the statement
using the following logic: If cell B2 = 2, then add text "00" to the front
of what's in cell A2 (="00"&A2).

SDF Character Result
A2: 63 B2:2 C2:0063

Thanks!
Jaret
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default Need help with If statement

=IF(B2=2,"00"&A2,"")

I don't know what you want for the false statement so I put a "" value
--
Kevin Backmann


"mcmilja" wrote:

Hello,

I need help with a nested if statement. How would I build the statement
using the following logic: If cell B2 = 2, then add text "00" to the front
of what's in cell A2 (="00"&A2).

SDF Character Result
A2: 63 B2:2 C2:0063

Thanks!
Jaret

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35
Default Need help with If statement

Thanks Kevin! How would I throw in several ORs into the statement?

If cell B2 = 1, then add text "000" to A2 (="000"&A2)
If cell B2 = 2, then add text "00" to A2 (="00"&A2) OR
If cell B2 = 3, then add text "0" to A2 (="0"&A2) OR
If cell B2 = 4, then add nothing to A2 (=""&A2) OR

SDF Characters Result
A2:9 B2:1 C2:0009
A2:63 B2:2 C2:0063
A2:105 B2:3 C2:0105
A2:1005 B2:4 C2:1005

"Kevin B" wrote:

=IF(B2=2,"00"&A2,"")

I don't know what you want for the false statement so I put a "" value
--
Kevin Backmann


"mcmilja" wrote:

Hello,

I need help with a nested if statement. How would I build the statement
using the following logic: If cell B2 = 2, then add text "00" to the front
of what's in cell A2 (="00"&A2).

SDF Character Result
A2: 63 B2:2 C2:0063

Thanks!
Jaret

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default Need help with If statement

The following formula pads your values based upon their respective lengths.
If the length of the value is equal to or greater than 4 you get the value,
otherwise the CHOOSE function pads zeroes based upon lenghts 1, 2 and 3:

=IF(LEN(A1)=4,A1,CHOOSE(LEN(A1),"000"&A1,"00"&A1, "0"&A1))
--
Kevin Backmann


"mcmilja" wrote:

Thanks Kevin! How would I throw in several ORs into the statement?

If cell B2 = 1, then add text "000" to A2 (="000"&A2)
If cell B2 = 2, then add text "00" to A2 (="00"&A2) OR
If cell B2 = 3, then add text "0" to A2 (="0"&A2) OR
If cell B2 = 4, then add nothing to A2 (=""&A2) OR

SDF Characters Result
A2:9 B2:1 C2:0009
A2:63 B2:2 C2:0063
A2:105 B2:3 C2:0105
A2:1005 B2:4 C2:1005

"Kevin B" wrote:

=IF(B2=2,"00"&A2,"")

I don't know what you want for the false statement so I put a "" value
--
Kevin Backmann


"mcmilja" wrote:

Hello,

I need help with a nested if statement. How would I build the statement
using the following logic: If cell B2 = 2, then add text "00" to the front
of what's in cell A2 (="00"&A2).

SDF Character Result
A2: 63 B2:2 C2:0063

Thanks!
Jaret

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can an If statement answer an If statement? M.A.Tyler Excel Discussion (Misc queries) 2 June 24th 07 04:14 AM
If statement ghost Excel Discussion (Misc queries) 4 April 29th 07 05:30 PM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM
If statement and Isblank statement Rodney C. Excel Worksheet Functions 0 January 18th 05 08:39 PM
Help please, IF statement/SUMIF statement Brad_A Excel Worksheet Functions 23 January 11th 05 02:24 PM


All times are GMT +1. The time now is 07:40 PM.

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

About Us

"It's about Microsoft Excel"