Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / May 2008

Tip: Looking for answers? Try searching our database.

Only adding nonzeroes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BryGuy77 - 21 May 2008 05:54 GMT
Hello all,

In Excel 2007, have a data array that contains blank lines. Is it possible
to list only the cells with values? Ill give an example:

A1='blank'
A2='blank'
A3=5/5/08
A4='blank'
A5=7/7/08

Can I list this so it ends with: 5/5/08, 7/7/08? I tried CONCATENATE, but
the blanks return ", ". And now I'm lost.
Stefi - 21 May 2008 11:44 GMT
Please, post your CONCATENATE formula!
Regards,
Stefi

„BryGuy77” ezt írta:

> Hello all,
>
[quoted text clipped - 9 lines]
> Can I list this so it ends with: 5/5/08, 7/7/08? I tried CONCATENATE, but
> the blanks return ", ". And now I'm lost.
Gord Dibben - 22 May 2008 01:06 GMT
To leave out the blank cells you will have to concatenate just the ones with
data.

=A3 & "," & A5

Or use this UDF which ignores blank cells and comma-delimits those with data.

Function ConCatRange(CellBlock As Range) As String
Dim Cell As Range
Dim sbuf As String
   For Each Cell In CellBlock
       If Len(Cell.text) > 0 Then sbuf = sbuf & Cell.text & ","
   Next
   ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function

Usage is  =concatrange(A1:A5)  which returns  5/5/08,7/7/08

If you're not familiar with VBA and macros/functions, see David McRitchie's site
for more on "getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

or Ron de De Bruin's site on where to store macros.

http://www.rondebruin.nl/code.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + r to open Project Explorer.

Find your workbook/project and select it.

Right-click and Insert>Module.  Paste the code in there.  Save the
workbook and hit ALT + Q to return to your workbook.

In a cell enter the formula as shown above in Usage is:

Gord Dibben  MS Excel MVP

Gord Dibben  MS Excel MVP

>Hello all,
>
[quoted text clipped - 9 lines]
>Can I list this so it ends with: 5/5/08, 7/7/08? I tried CONCATENATE, but
>the blanks return ", ". And now I'm lost.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.