Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Help with If,then statement Returning Value (or Select Case)

Hello, any help is appreciated. I have four cells (A1 thru A4). I want
to display (1) in B1 if just A1 contains any text, or I want to display
(1) and (2) in B1 if cells A1 and A2 both contain text, or display
(1),(2), and (3) in B1 if A1,A2,and A3 contain text, or display (1),
(2), (3), and (4) in B1 if A1 thru A4 have any text in them.

Sorry if this has already been covered somewhere...I did check...Thanks
for any help guys/gals.

Bull

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help with If,then statement Returning Value (or Select Case)

Can you live with something like:

(1),(2),(4)

If yes, you could use this formula in B1:

=SUBSTITUTE(TRIM(IF(A1="","","(1) ")
& IF(A2="","","(2) ") & IF(A3="","","(3) ") & IF(A4="","","(4) "))," ",",")



wrote:

Hello, any help is appreciated. I have four cells (A1 thru A4). I want
to display (1) in B1 if just A1 contains any text, or I want to display
(1) and (2) in B1 if cells A1 and A2 both contain text, or display
(1),(2), and (3) in B1 if A1,A2,and A3 contain text, or display (1),
(2), (3), and (4) in B1 if A1 thru A4 have any text in them.

Sorry if this has already been covered somewhere...I did check...Thanks
for any help guys/gals.

Bull


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Help with If,then statement Returning Value (or Select Case)

Thank you. It would be ok if it was up to me...but it requires a little
more...but again, appreciate your help.
Dave Peterson wrote:
Can you live with something like:

(1),(2),(4)

If yes, you could use this formula in B1:

=SUBSTITUTE(TRIM(IF(A1="","","(1) ")
& IF(A2="","","(2) ") & IF(A3="","","(3) ") & IF(A4="","","(4) "))," ",",")



wrote:

Hello, any help is appreciated. I have four cells (A1 thru A4). I want
to display (1) in B1 if just A1 contains any text, or I want to display
(1) and (2) in B1 if cells A1 and A2 both contain text, or display
(1),(2), and (3) in B1 if A1,A2,and A3 contain text, or display (1),
(2), (3), and (4) in B1 if A1 thru A4 have any text in them.

Sorry if this has already been covered somewhere...I did check...Thanks
for any help guys/gals.

Bull


--

Dave Peterson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Help with If,then statement Returning Value (or Select Case)

wow, thanks. I am trying to figure out how to put this one in.
Martin Fishlock wrote:
Dear Mrs Bull Foreman:

This is one way to do it:

Dim szAns As String
With ActiveSheet.Range("A1:A4")
If .Cells(1) = "" Then
szAns = ""
Else
szAns = "(1)"
If .Cells(2) < "" Then
If .Cells(3) = "" Then
szAns = szAns & " and (2)"
Else
szAns = szAns & ", (2)"
If .Cells(4) = "" Then
szAns = szAns & " and (3)"
Else
szAns = szAns & ", (3) and (4)"
End If
End If
End If
End If
End With

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


" wrote:

Hello, any help is appreciated. I have four cells (A1 thru A4). I want
to display (1) in B1 if just A1 contains any text, or I want to display
(1) and (2) in B1 if cells A1 and A2 both contain text, or display
(1),(2), and (3) in B1 if A1,A2,and A3 contain text, or display (1),
(2), (3), and (4) in B1 if A1 thru A4 have any text in them.

Sorry if this has already been covered somewhere...I did check...Thanks
for any help guys/gals.

Bull



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Help with If,then statement Returning Value (or Select Case)

thanks, this fixed it giles...appreciate everyone's help here. Take
care. BULL
Giles (NoSpam) wrote:
Here is a nice simple formula to put in cell B1

=CHOOSE(COUNTA(A1:A4),"(1)","(1)(2)","(1)(2)(3)"," (1)(2)(3)(4)")

hth

Giles

" wrote:

Hello, any help is appreciated. I have four cells (A1 thru A4). I want
to display (1) in B1 if just A1 contains any text, or I want to display
(1) and (2) in B1 if cells A1 and A2 both contain text, or display
(1),(2), and (3) in B1 if A1,A2,and A3 contain text, or display (1),
(2), (3), and (4) in B1 if A1 thru A4 have any text in them.

Sorry if this has already been covered somewhere...I did check...Thanks
for any help guys/gals.

Bull



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
Select Case Statement Katie Excel Worksheet Functions 13 December 1st 08 07:32 PM
select case statement? CR[_2_] Excel Programming 5 December 20th 06 09:21 PM
Select Case within IF-Else statement rwnelson Excel Programming 8 April 6th 06 06:47 PM
select case statement jrd269[_4_] Excel Programming 4 June 3rd 05 04:22 PM
Convert If..Else to Select Case Statement. Sheela Excel Programming 1 July 25th 03 09:28 AM


All times are GMT +1. The time now is 03:58 AM.

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"