![]() |
How to define
Okay I have a function that in development I was just hitting from the
worksheet. So in a cell I would enter =concat_clean(A1:Z1) ------------------------------------------------ Sub Concat_Clean(Attr) Dim C As Range Dim S As String, V As String, X As String S = "" For Each C In Attr V = C.Value If Len(S) + Len(V) < 55 Then If V < "" Then If S < "" Then S = S & " " & V Else S = V End If End If End If Next C Concat_Clean = S End Sub ------------------------------------------------ Now I want to implement this function as a call from another function. I seem to be having problems passing a value like A1:Z1 via a variable to in so that it all functions. I assume it is all dependant on the type of variable it is, but I can't seem to figure out how to do it properly. |
How to define
Make your procedure a function, then use something like: msgbox concat_clean(range("a1:z1")) Co -- colofnatur ----------------------------------------------------------------------- colofnature's Profile: http://www.excelforum.com/member.php...fo&userid=3435 View this thread: http://www.excelforum.com/showthread.php?threadid=55933 |
How to define
Hi Robert,
The following worked for me: '============= Public Sub TestIt() Dim sStr As String sStr = Concat_Clean(Range("A1:Z1")) MsgBox sStr End Sub '<<============= --- Regards, Norman wrote in message ups.com... Okay I have a function that in development I was just hitting from the worksheet. So in a cell I would enter =concat_clean(A1:Z1) ------------------------------------------------ Sub Concat_Clean(Attr) Dim C As Range Dim S As String, V As String, X As String S = "" For Each C In Attr V = C.Value If Len(S) + Len(V) < 55 Then If V < "" Then If S < "" Then S = S & " " & V Else S = V End If End If End If Next C Concat_Clean = S End Sub ------------------------------------------------ Now I want to implement this function as a call from another function. I seem to be having problems passing a value like A1:Z1 via a variable to in so that it all functions. I assume it is all dependant on the type of variable it is, but I can't seem to figure out how to do it properly. |
How to define
Hi Col,
Make your procedure a function Given: Okay I have a function that in development I was just hitting from the worksheet. So in a cell I would enter =concat_clean(A1:Z1) I assumed that Robert was using a function and the 'Sub' is a typo. It is wise, however, to make as few assumptions as possible! --- Regards, Norman |
All times are GMT +1. The time now is 02:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com