Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default defign a function in one workbook and use it in another workbook

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default defign a function in one workbook and use it in another workbook

=mybook.xls!myfunc()

--
HTH

Bob Phillips

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

"Dean@ERYC" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default defign a function in one workbook and use it in another workbook

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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default defign a function in one workbook and use it in another workbo

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" wrote in message
...
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
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
REPT FUNCTION FROM WORKBOOK TO WORKBOOK CHESTER Excel Worksheet Functions 1 December 15th 07 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 Excel Programming 1 April 1st 06 08:48 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Excel Programming 9 July 25th 05 12:44 PM
Call function from one workbook that resides in another workbook m Datasort Excel Programming 3 January 16th 05 10:33 PM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


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