PC Review


Reply
Thread Tools Rate Thread

defign a function in one workbook and use it in another workbook

 
 
=?Utf-8?B?RGVhbkBFUllD?=
Guest
Posts: n/a
 
      17th Oct 2006
I am trying to open a workbook eg book2.xls from vba code in book1.xls and
want to then use a user defigned function defigned in book1.xls in book2.xls.

I can open book2.xls ok and can insert columns and paste 'normal' excel
functions into the cells but want to paste a user defigned function in and
cannot work out how to do it.

Any help greatly aprechiated.

Dean.
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      17th Oct 2006
=mybook.xls!myfunc()

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dean@ERYC" <(E-Mail Removed)> wrote in message
news:28AE2091-A4B9-4D6E-AEA4-(E-Mail Removed)...
> I am trying to open a workbook eg book2.xls from vba code in book1.xls and
> want to then use a user defigned function defigned in book1.xls in

book2.xls.
>
> I can open book2.xls ok and can insert columns and paste 'normal' excel
> functions into the cells but want to paste a user defigned function in and
> cannot work out how to do it.
>
> Any help greatly aprechiated.
>
> Dean.



 
Reply With Quote
 
=?Utf-8?B?RGVhbkBFUllD?=
Guest
Posts: n/a
 
      17th Oct 2006
The following code works:
Columns("W:W").Select
Selection.Insert Shift:=xlToRight
Range("W1").Select
ActiveCell.FormulaR1C1 = "ERROR SUBMISSION DATE"
Range("W2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]="""",""ERROR"","""")"
Range("W2").Select
Columns("W:W").EntireColumn.AutoFit
Set SourceRange = Range("W2")
Set fillRange = Range("W2:W" & howmany)
SourceRange.AutoFill Destination:=fillRange
Columns("W:W").Select
Selection.Font.ColorIndex = 3
Range("W2").Select

But instead of the If statement I want to run:
Function dean1(rdl1 As String, rdl2 As String)
Dim rdla As String
If rdl1 = "Lab1" Or "Lab2" Or "Lab3" And rdl2 = "" Then rdla = "Error" Else
rdla = ""
dean1 = Trim(rdla)
End Function

Don't know if this helps!

Cheers, Dean.
"Dean@ERYC" wrote:

> I am trying to open a workbook eg book2.xls from vba code in book1.xls and
> want to then use a user defigned function defigned in book1.xls in book2.xls.
>
> I can open book2.xls ok and can insert columns and paste 'normal' excel
> functions into the cells but want to paste a user defigned function in and
> cannot work out how to do it.
>
> Any help greatly aprechiated.
>
> Dean.

 
Reply With Quote
 
=?Utf-8?B?RGVhbkBFUllD?=
Guest
Posts: n/a
 
      17th Oct 2006
Thankyou Bob, that's sorted it.

"Bob Phillips" wrote:

> =mybook.xls!myfunc()
>
> --
> HTH
>
> Bob Phillips
>
> (replace somewhere in email address with gmail if mailing direct)
>
> "Dean@ERYC" <(E-Mail Removed)> wrote in message
> news:28AE2091-A4B9-4D6E-AEA4-(E-Mail Removed)...
> > I am trying to open a workbook eg book2.xls from vba code in book1.xls and
> > want to then use a user defigned function defigned in book1.xls in

> book2.xls.
> >
> > I can open book2.xls ok and can insert columns and paste 'normal' excel
> > functions into the cells but want to paste a user defigned function in and
> > cannot work out how to do it.
> >
> > Any help greatly aprechiated.
> >
> > Dean.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
REPT FUNCTION FROM WORKBOOK TO WORKBOOK CHESTER Microsoft Excel Worksheet Functions 1 15th Dec 2007 03:19 PM
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Microsoft Excel Programming 1 1st Apr 2006 08:48 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Microsoft Excel Programming 9 25th Jul 2005 12:44 PM
Call function from one workbook that resides in another workbook m =?Utf-8?B?RGF0YXNvcnQ=?= Microsoft Excel Programming 3 16th Jan 2005 10:33 PM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Microsoft Excel Programming 1 24th Jul 2003 11:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:57 PM.