PC Review


Reply
Thread Tools Rate Thread

creating functions

 
 
=?Utf-8?B?Q3JlYXRpbmcgRnVuY3Rpb25zIGluIEV4Y2Vs?=
Guest
Posts: n/a
 
      3rd Sep 2007
I am missing something fundamental in creating functions in Excel. Does
somebody have step by step, comprehensive instructions?

At this point, I somehow have a simple function that is recognized and
returns a 0 value, but does not appear in the VB Editor or in the list of
functions. Two other simple functions - same as the first with slightly
different names - appear in the list of functions and in the VB Editor, but
are not recognized when I insert the names into the corresponding spread
sheet.

Help would be appreciated,

Jim
 
Reply With Quote
 
 
 
 
Ron Rosenfeld
Guest
Posts: n/a
 
      3rd Sep 2007
On Mon, 3 Sep 2007 05:08:01 -0700, Creating Functions in Excel <Creating
Functions in (E-Mail Removed)> wrote:

>I am missing something fundamental in creating functions in Excel. Does
>somebody have step by step, comprehensive instructions?
>
>At this point, I somehow have a simple function that is recognized and
>returns a 0 value, but does not appear in the VB Editor or in the list of
>functions. Two other simple functions - same as the first with slightly
>different names - appear in the list of functions and in the VB Editor, but
>are not recognized when I insert the names into the corresponding spread
>sheet.
>
>Help would be appreciated,
>
>Jim


Make sure your functions have unique names. (You can also use fully-qualified
names, but this is a PITA).

Make sure they are in a regular module, and not a workbook or worksheet module.
--ron
 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      3rd Sep 2007
Generally speaking, the best way to make functions (UDFs) "findable" from the
VBE environment and "reachable" from the worksheet is to:

1. Insert them in standard modules
2. Declare them Public

Public Function bumpit(i As Integer) As Integer
bumpit = i + 1
End Function
--
Gary''s Student - gsnu200742


"Creating Functions in Excel" wrote:

> I am missing something fundamental in creating functions in Excel. Does
> somebody have step by step, comprehensive instructions?
>
> At this point, I somehow have a simple function that is recognized and
> returns a 0 value, but does not appear in the VB Editor or in the list of
> functions. Two other simple functions - same as the first with slightly
> different names - appear in the list of functions and in the VB Editor, but
> are not recognized when I insert the names into the corresponding spread
> sheet.
>
> Help would be appreciated,
>
> Jim

 
Reply With Quote
 
=?Utf-8?B?Q3JlYXRpbmcgRnVuY3Rpb25zIGluIEV4Y2Vs?=
Guest
Posts: n/a
 
      3rd Sep 2007
Hi,

Thanks. Sorry if I sound dim, but how do I insert functions into standard
modules rather than workbook or worksheet modules?

Jim


"Ron Rosenfeld" wrote:

> On Mon, 3 Sep 2007 05:08:01 -0700, Creating Functions in Excel <Creating
> Functions in (E-Mail Removed)> wrote:
>
> >I am missing something fundamental in creating functions in Excel. Does
> >somebody have step by step, comprehensive instructions?
> >
> >At this point, I somehow have a simple function that is recognized and
> >returns a 0 value, but does not appear in the VB Editor or in the list of
> >functions. Two other simple functions - same as the first with slightly
> >different names - appear in the list of functions and in the VB Editor, but
> >are not recognized when I insert the names into the corresponding spread
> >sheet.
> >
> >Help would be appreciated,
> >
> >Jim

>
> Make sure your functions have unique names. (You can also use fully-qualified
> names, but this is a PITA).
>
> Make sure they are in a regular module, and not a workbook or worksheet module.
> --ron
>

 
Reply With Quote
 
=?Utf-8?B?Q3JlYXRpbmcgRnVuY3Rpb25zIGluIEV4Y2Vs?=
Guest
Posts: n/a
 
      3rd Sep 2007
Hi,

Thanks. Sorry if I sound dim, but how do I insert functions into standard
modules rather than workbook or worksheet modules?

Jim

"Gary''s Student" wrote:

> Generally speaking, the best way to make functions (UDFs) "findable" from the
> VBE environment and "reachable" from the worksheet is to:
>
> 1. Insert them in standard modules
> 2. Declare them Public
>
> Public Function bumpit(i As Integer) As Integer
> bumpit = i + 1
> End Function
> --
> Gary''s Student - gsnu200742
>
>
> "Creating Functions in Excel" wrote:
>
> > I am missing something fundamental in creating functions in Excel. Does
> > somebody have step by step, comprehensive instructions?
> >
> > At this point, I somehow have a simple function that is recognized and
> > returns a 0 value, but does not appear in the VB Editor or in the list of
> > functions. Two other simple functions - same as the first with slightly
> > different names - appear in the list of functions and in the VB Editor, but
> > are not recognized when I insert the names into the corresponding spread
> > sheet.
> >
> > Help would be appreciated,
> >
> > Jim

 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      3rd Sep 2007
User Defined Functions (UDFs) are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the UDF will be saved with it.

To remove the UDF:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To use the UDF from Excel:

=myfunction(A1)

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Gary''s Student - gsnu200742


"Creating Functions in Excel" wrote:

> Hi,
>
> Thanks. Sorry if I sound dim, but how do I insert functions into standard
> modules rather than workbook or worksheet modules?
>
> Jim
>
> "Gary''s Student" wrote:
>
> > Generally speaking, the best way to make functions (UDFs) "findable" from the
> > VBE environment and "reachable" from the worksheet is to:
> >
> > 1. Insert them in standard modules
> > 2. Declare them Public
> >
> > Public Function bumpit(i As Integer) As Integer
> > bumpit = i + 1
> > End Function
> > --
> > Gary''s Student - gsnu200742
> >
> >
> > "Creating Functions in Excel" wrote:
> >
> > > I am missing something fundamental in creating functions in Excel. Does
> > > somebody have step by step, comprehensive instructions?
> > >
> > > At this point, I somehow have a simple function that is recognized and
> > > returns a 0 value, but does not appear in the VB Editor or in the list of
> > > functions. Two other simple functions - same as the first with slightly
> > > different names - appear in the list of functions and in the VB Editor, but
> > > are not recognized when I insert the names into the corresponding spread
> > > sheet.
> > >
> > > Help would be appreciated,
> > >
> > > Jim

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      3rd Sep 2007
Jim,

See http://www.cpearson.com/excel/Writin...ionsInVBA.aspx for a
step-by-step guide to writing User Defined Functions in VBA.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Creating Functions in Excel" <Creating Functions in
(E-Mail Removed)> wrote in message
news:C039499D-A059-41A5-9723-(E-Mail Removed)...
>I am missing something fundamental in creating functions in Excel. Does
> somebody have step by step, comprehensive instructions?
>
> At this point, I somehow have a simple function that is recognized and
> returns a 0 value, but does not appear in the VB Editor or in the list of
> functions. Two other simple functions - same as the first with slightly
> different names - appear in the list of functions and in the VB Editor,
> but
> are not recognized when I insert the names into the corresponding spread
> sheet.
>
> Help would be appreciated,
>
> Jim


 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      3rd Sep 2007
On Mon, 3 Sep 2007 05:56:00 -0700, Creating Functions in Excel
<(E-Mail Removed)> wrote:

>Hi,
>
>Thanks. Sorry if I sound dim, but how do I insert functions into standard
>modules rather than workbook or worksheet modules?
>
>Jim


After opening the VB Editor, and selecting your project, you select
Insert/Module and enter your code into the window that opens.

In the subtree under your project, you will see something like:

VBAProject(Book2)
Microsoft Excel Objects
Sheet1
Sheet2
ThisWorkbook
Modules
Module1

Your code should be in "Module1"
--ron
 
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
Creating Functions C# Jl_G_0 Microsoft ASP .NET 3 13th Sep 2007 04:31 PM
Creating VBA Functions When Creating Spreadsheet Via VBA? PeteCresswell Microsoft Excel Programming 6 18th Jun 2007 12:38 PM
Creating functions =?Utf-8?B?U3RldmU=?= Microsoft Excel Programming 2 22nd Jan 2006 08:47 PM
Creating Help within functions Joe Carroll Microsoft Excel Programming 1 5th Jun 2005 03:56 AM
Creating Functions Lynxbci3 Microsoft Excel Misc 1 22nd Sep 2004 04:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:50 PM.