ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with If,then statement Returning Value (or Select Case) (https://www.excelbanter.com/excel-programming/379800-help-if-then-statement-returning-value-select-case.html)

[email protected]

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


Dave Peterson

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

[email protected]

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



[email protected]

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




[email protected]

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





All times are GMT +1. The time now is 02:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com