Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Define name | Excel Programming | |||
Define name | Excel Programming | |||
Name Define | Excel Discussion (Misc queries) | |||
define name | Excel Discussion (Misc queries) | |||
Name define | Excel Programming |