Saturday, January 8, 2011

Function to concatenate non blank cells

user define function to concatenate the non empty cells

For Example:-

function given below--

Function connonempty(x As Range) As String
Dim y As Range
Dim hh As String
hh = ""
For Each y In x

If Not IsEmpty(y) Then
hh = hh & y & ","

End If

Next y

If Right(hh, 1) = "," Then

hh = Left(hh, Len(hh) - 1)

End If

connonempty = hh

End Function

type like : =connonempty(B2:H2)

No comments:

Post a Comment

Import data from SQL

Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...