Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
b w b w is offline
external usenet poster
 
Posts: 3
Default Concatenate a string when cells are not zero

I'd like to know how to concatenate when the value of the B cells are
non-zero as follows:

="The result is as follows...Detail: " & A1 & B1 & A2 & B2 & A3 & B3
&...Ax & Bx & "Total=" & Text(Sum(B1:Bx),"$#,##0.00"

If a B cell value is zero, then don't concatenate with the corresponding
A cell.

The result should be something like this:
Result is as follows...Detail: Hotel=$150.00, Gasoline=$75.00,
Total=$225.00

Thanks,
Bernie

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenate a string when cells are not zero


are you doing this via a macro or in-cell?

if your doing it in-cell, then use an if equation.

=if(B1="0","0",concatenate(......))

if your doing macro, I'll have to think about it for a minute. If it
is a macro, could you include more info, input, variables, etc...


--
dok112
------------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...o&userid=10581
View this thread: http://www.excelforum.com/showthread...hreadid=481719

  #3   Report Post  
Posted to microsoft.public.excel.programming
b w b w is offline
external usenet poster
 
Posts: 3
Default Concatenate a string when cells are not zero

Thanks for the reply.

I'm trying to do this in-cell, but your solution indicates that I didn't
explain myself very well.

If B1 is zero, then your expression works, but I want to do this for ALL
B cells that are zero. An IF statement wouldn't be too practical if I
were looking at more than a few values of B.

As an example, If B1 and B2 and B3 are NOT zero, then my equation would
be =(A1 & B1) & (A2 & B2) & (A3 & B3).

But if B2 was Zero, then the equation would be:
=(A1 & B1) & (A3 & B3).

I was thinking that maybe an Array Formula would be the solution, but I
don't know, which is why I have posed the problem.

Thanks,
Bernie




*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Concatenate a string when cells are not zero

Maybe with a UDF:

Function Tot(Descriptions As Range, Costs As Range)
Dim cell As Range
If Descriptions.Columns.Count 1 Or _
Costs.Columns.Count 1 Then
Tot = CVErr(xlErrRef)
ElseIf Descriptions.Rows.Count < Costs.Rows.Count Then
Tot = CVErr(xlErrNA)
Else
For Each cell In Costs
If cell.Value < 0 Then
Tot = Tot & cell.Offset(0, -1).Value & _
"=$" & cell.Value & ", "
End If
Next cell
Tot = "Detail: " & Tot & "Total=$" & Application. _
WorksheetFunction.Sum(Costs)
End If
End Function

Enter in a cell = tot(A1:A5,B1:B5) where column A has the descriptions
and column B the costs.

Hope this helps
Rowan

b w wrote:
Thanks for the reply.

I'm trying to do this in-cell, but your solution indicates that I didn't
explain myself very well.

If B1 is zero, then your expression works, but I want to do this for ALL
B cells that are zero. An IF statement wouldn't be too practical if I
were looking at more than a few values of B.

As an example, If B1 and B2 and B3 are NOT zero, then my equation would
be =(A1 & B1) & (A2 & B2) & (A3 & B3).

But if B2 was Zero, then the equation would be:
=(A1 & B1) & (A3 & B3).

I was thinking that maybe an Array Formula would be the solution, but I
don't know, which is why I have posed the problem.

Thanks,
Bernie




*** Sent via Developersdex http://www.developersdex.com ***

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Concatenate a string when cells are not zero

Concatenation doesn't work with array formulas although Laraunt Longre has a
free addin that offers functions that support it.

You want the
Morefunc.xll update 18/10/2005

on the English page.


If you just want a formula, it isn't too bad

If(sum(B1:B3)=0,"",if(B1=0,"",A1 & "=" & Text(B1,"$#,##0.00) & ", ") &
if(B2=0,"",A2&"="&Text(B2,"$#,##0.00)&", ") &
if(B3=0,"",A3&"="&Text(B2,"$#,##0.00)&", "))

Have to play with it to eliminate an ending comma.
--
Regards,
Tom Ogilvy




"b w" wrote in message
...
Thanks for the reply.

I'm trying to do this in-cell, but your solution indicates that I didn't
explain myself very well.

If B1 is zero, then your expression works, but I want to do this for ALL
B cells that are zero. An IF statement wouldn't be too practical if I
were looking at more than a few values of B.

As an example, If B1 and B2 and B3 are NOT zero, then my equation would
be =(A1 & B1) & (A2 & B2) & (A3 & B3).

But if B2 was Zero, then the equation would be:
=(A1 & B1) & (A3 & B3).

I was thinking that maybe an Array Formula would be the solution, but I
don't know, which is why I have posed the problem.

Thanks,
Bernie




*** Sent via Developersdex http://www.developersdex.com ***





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
logical test and concatenate(string) dpayne Excel Discussion (Misc queries) 7 April 5th 07 08:30 PM
Concatenate in a string IntricateFool Excel Worksheet Functions 4 June 7th 06 07:29 PM
Opposite of Concatenate (Breaking apart a string) XMLCimo Excel Worksheet Functions 1 March 5th 06 12:20 AM
string concatenate DorisM Excel Programming 3 July 7th 05 01:39 AM
concatenate a text string if two different cells contain the sam. Linda G Excel Worksheet Functions 5 January 17th 05 07:53 PM


All times are GMT +1. The time now is 12:15 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"