MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 28th, 2002, 09:55 PM   #1
Andrew XJ
Board Regular
 
Join Date: Feb 2002
Location: Singapore
Posts: 77
Default

I need to write some user defined fuctions and these fuctions will be used by Excel cells in spreadsheets.
Now the problem is that i can't use Excel Embeded fuctions such as "Find", "Select", etc. Could you help me with this problem?
In fact i also want to know how the Excel embeded functions are defined.

regards
Andrew XJ

_________________
Regards
XJ

[ This Message was edited by: Andrew XJ on 2002-04-28 22:18 ]
Andrew XJ is offline   Reply With Quote
Old Apr 28th, 2002, 11:21 PM   #2
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Hi Andrew...
Why can't you use the Excel funtions in your function?
Student?
What is your function attempting to accomplish?
Tom
Tom Schreiner is offline   Reply With Quote
Old May 2nd, 2002, 06:19 AM   #3
Andrew XJ
Board Regular
 
Join Date: Feb 2002
Location: Singapore
Posts: 77
Default

you can assign formulas to Cells, rite? What i need to do is writing my own formulas. But the problem is that my own formula can only assign return value. I can't call Excel embedded functions in my function.
__________________
Regards
XJ
Andrew XJ is offline   Reply With Quote
Old May 2nd, 2002, 06:22 AM   #4
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Quote:
On 2002-05-02 05:19, Andrew XJ wrote:
you can assign formulas to Cells, rite? What i need to do is writing my own formulas. But the problem is that my own formula can only assign return value. I can't call Excel embedded functions in my function.
What exactly are you trying to do with your
UDF...?? perhaps we can help...
__________________
Kind Regards,
Ivan F Moala From the City of Sails
Ivan F Moala is offline   Reply With Quote
Old May 2nd, 2002, 07:17 AM   #5
Andrew XJ
Board Regular
 
Join Date: Feb 2002
Location: Singapore
Posts: 77
Default

it's a general question.
e.g, i need to write a formula named by RECIPROCAL(). I can create a module and a function:
Function RECIPROCAL(Byval input1 As Double) As Double
RECIPROCAL = 1/input1
End Function

This simple function of cos will cause no problem. But what if i need to add some action in the function or call some Excel Embedded function.

Function RECIPROCAL(Byval input1 As Double) As Double
RECIPROCAL = 1/input1
Range("A1") = "test"
'or Sheets("Sheet1").select
'or Range("A1:H99").Find("testing").Select
End Function

Then the function RECIPROCAL can't work properly.
So how to solve this problem?



__________________
Regards
XJ
Andrew XJ is offline   Reply With Quote
Old May 2nd, 2002, 09:21 AM   #6
Andrew XJ
Board Regular
 
Join Date: Feb 2002
Location: Singapore
Posts: 77
Default

In fact, most embedded formulas needs to call other functions or formulas. How can these formulas can do that but mine own can not? Could anyone tell me how to see the codes of some embedded formulas such as SUMIF.
__________________
Regards
XJ
Andrew XJ is offline   Reply With Quote
Old May 2nd, 2002, 11:37 PM   #7
Andrew XJ
Board Regular
 
Join Date: Feb 2002
Location: Singapore
Posts: 77
Default

Can anyone enlighten me that?

Thx
__________________
Regards
XJ
Andrew XJ is offline   Reply With Quote
Old May 3rd, 2002, 12:14 AM   #8
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
Default

UDF's can't select, change, modify, or whatever you can think of, the environment of the spreadsheet. They can only return a value.

Why SUMIF works with other sheets ? simply, because it doesn't select anything. Actually, you don't need (99% of the time) to select anything in your macros for them to work properly.
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González is offline   Reply With Quote
Old May 3rd, 2002, 01:12 PM   #9
Andrew XJ
Board Regular
 
Join Date: Feb 2002
Location: Singapore
Posts: 77
Default

Juan Pablo, i agree with you that select can be avoided in most cases. But how about function Find? This function is very useful in UDF. Then do you mean that the only way is to implement the find function using UDF by for loop?? this is the only way i can think of.......
__________________
Regards
XJ
Andrew XJ is offline   Reply With Quote
Old May 3rd, 2002, 02:24 PM   #10
Jack in the UK
Board Regular
 
Join Date: Feb 2002
Posts: 3,065
Default

If it any help i keep UDF as simple as poss like Juan says they will only return a value, ok you throw them in them in the mixer and carry out commands / action but to me UDF is USer Defined function so will make some math run on a cell and return some result EXACTLY as you want.

so i would stick to that and make a command button or target code make the changes on a different script

some ideas,

__________________
Free Excel based Web Toolbar available here.

Jack in the UK
J & R Excel Solutions
"making Excel work for you"
Jack in the UK is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On

Forum Jump


All times are GMT -4. The time now is 04:09 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes