Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default create function with passing parameters

i want to create my own function with passing parameters. Here's the case :

Cell A1 = 5
Cell B1 = 0

and I want cell C1 = 00005

i have this function but i don't know how to insert in macro :

Function TextInfix(CurrChar As String, CharInfix As String, TextLong As
Integer) As String
Dim CharLong As Integer, TmpInfix$

CharLong = Len(CurrChar)

TmpInfix = String(TextLong - CharLong, CharInfix) & CurrChar

TextInfix = TmpInfix
End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default create function with passing parameters

Is this what you want

Function TextInfix(CurrChar As String, CharInfix As String, _
TextLong As Integer) As String

TextInfix = Application.Rept(CharInfix, TextLong) & CurrChar
End Function


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"DASmania Cool" <DASmania wrote in message
...
i want to create my own function with passing parameters. Here's the case

:

Cell A1 = 5
Cell B1 = 0

and I want cell C1 = 00005

i have this function but i don't know how to insert in macro :

Function TextInfix(CurrChar As String, CharInfix As String, TextLong As
Integer) As String
Dim CharLong As Integer, TmpInfix$

CharLong = Len(CurrChar)

TmpInfix = String(TextLong - CharLong, CharInfix) & CurrChar

TextInfix = TmpInfix
End Function



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default create function with passing parameters

Thank you Bob Phillips

Yes, your code makes it so simple.

And now there are another problem, I create this function at PERSONAL.XLS
and I'm able to run the function in PERSONAL.XLS but i can't run it at
another workbook.

Do you know why this things happened ?

"Bob Phillips" wrote:

Is this what you want

Function TextInfix(CurrChar As String, CharInfix As String, _
TextLong As Integer) As String

TextInfix = Application.Rept(CharInfix, TextLong) & CurrChar
End Function


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"DASmania Cool" <DASmania wrote in message
...
i want to create my own function with passing parameters. Here's the case

:

Cell A1 = 5
Cell B1 = 0

and I want cell C1 = 00005

i have this function but i don't know how to insert in macro :

Function TextInfix(CurrChar As String, CharInfix As String, TextLong As
Integer) As String
Dim CharLong As Integer, TmpInfix$

CharLong = Len(CurrChar)

TmpInfix = String(TextLong - CharLong, CharInfix) & CurrChar

TextInfix = TmpInfix
End Function




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default create function with passing parameters

Thank you Niek Otten

I create the function at PERSONAL.XLS & run perfectly on PERSONAL.XLS but i
cannot run it in another workbook, do you know why ?

"Niek Otten" wrote:

In Cell C1, enter

=textinfix(A1,B1,5)


--
Kind regards,

Niek Otten

"DASmania Cool" <DASmania wrote in message
...
i want to create my own function with passing parameters. Here's the case :

Cell A1 = 5
Cell B1 = 0

and I want cell C1 = 00005

i have this function but i don't know how to insert in macro :

Function TextInfix(CurrChar As String, CharInfix As String, TextLong As
Integer) As String
Dim CharLong As Integer, TmpInfix$

CharLong = Len(CurrChar)

TmpInfix = String(TextLong - CharLong, CharInfix) & CurrChar

TextInfix = TmpInfix
End Function






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default create function with passing parameters

You can do it with

=Personal.xls!TextInfix(char1,char2,len)

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"DASmania Cool" wrote in message
...
Thank you Bob Phillips

Yes, your code makes it so simple.

And now there are another problem, I create this function at PERSONAL.XLS
and I'm able to run the function in PERSONAL.XLS but i can't run it at
another workbook.

Do you know why this things happened ?

"Bob Phillips" wrote:

Is this what you want

Function TextInfix(CurrChar As String, CharInfix As String, _
TextLong As Integer) As String

TextInfix = Application.Rept(CharInfix, TextLong) & CurrChar
End Function


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"DASmania Cool" <DASmania wrote in

message
...
i want to create my own function with passing parameters. Here's the

case
:

Cell A1 = 5
Cell B1 = 0

and I want cell C1 = 00005

i have this function but i don't know how to insert in macro :

Function TextInfix(CurrChar As String, CharInfix As String, TextLong

As
Integer) As String
Dim CharLong As Integer, TmpInfix$

CharLong = Len(CurrChar)

TmpInfix = String(TextLong - CharLong, CharInfix) & CurrChar

TextInfix = TmpInfix
End Function






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default create function with passing parameters

Try:

=personal.xls!testinfix(a1,b1,5)

====
Another option is to save your personal.xls file as an addin (personal.xla).
Then you won't need that syntax.

But you won't see any macros in personal.xla in the tools|macro|macros dialog,
either.

DASmania Cool wrote:

Thank you Niek Otten

I create the function at PERSONAL.XLS & run perfectly on PERSONAL.XLS but i
cannot run it in another workbook, do you know why ?

"Niek Otten" wrote:

In Cell C1, enter

=textinfix(A1,B1,5)


--
Kind regards,

Niek Otten

"DASmania Cool" <DASmania wrote in message
...
i want to create my own function with passing parameters. Here's the case :

Cell A1 = 5
Cell B1 = 0

and I want cell C1 = 00005

i have this function but i don't know how to insert in macro :

Function TextInfix(CurrChar As String, CharInfix As String, TextLong As
Integer) As String
Dim CharLong As Integer, TmpInfix$

CharLong = Len(CurrChar)

TmpInfix = String(TextLong - CharLong, CharInfix) & CurrChar

TextInfix = TmpInfix
End Function





--

Dave Peterson
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
Passing parameters Cel Ref) to Sum function Shamshad Butt Excel Discussion (Misc queries) 4 October 26th 05 10:46 AM
Passing parameters to a called add-in... Trevor[_4_] Excel Programming 1 June 11th 04 11:12 PM
Passing parameters WarrenR Excel Programming 4 February 28th 04 09:11 PM
Passing parameters Eleanor[_2_] Excel Programming 0 February 4th 04 05:21 PM
Passing parameters to UDF mbobro[_3_] Excel Programming 5 January 2nd 04 04:25 PM


All times are GMT +1. The time now is 06:22 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"