Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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
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
Define name David Excel Programming 4 March 9th 06 09:19 PM
Define name davesexcel[_49_] Excel Programming 0 March 9th 06 01:19 AM
Name Define Ken Johnston Excel Discussion (Misc queries) 6 January 8th 06 03:04 PM
define name sunshine Excel Discussion (Misc queries) 1 March 29th 05 01:37 AM
Name define Alexander[_4_] Excel Programming 3 December 31st 03 02:16 PM


All times are GMT +1. The time now is 04:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"