Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Creating Complex Functions in the Worksheet Formula Bar - THIS ISNUTS!

This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.

Is there some sort of trick there? Outside in? Inside out?

Or some kind of editing tool?

Thanks.

SteveM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Creating Complex Functions in the Worksheet Formula Bar - THIS IS NUTS!


Perhaps you could help us understand your question.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"SteveM" wrote in message
...
This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.

Is there some sort of trick there? Outside in? Inside out?

Or some kind of editing tool?

Thanks.

SteveM


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Creating Complex Functions in the Worksheet Formula Bar - THIS ISNUTS!

On Nov 20, 9:28 am, SteveM wrote:
This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.

Is there some sort of trick there? Outside in? Inside out?

Or some kind of editing tool?

Thanks.

SteveM


Sure, I mean trying to stuff multiple functions inside the formula
bar. e.g, INDEX(IF(MAX(MIN(BLAH(BLAH(BLAH

I know what the functions mean, it's the mechanics of building the
formulas that are frustrating.

SteveM
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Creating Complex Functions in the Worksheet Formula Bar - THIS ISNUTS!

The way I do it is by creating smaller formulas using multiple cells,
then replacing the references in previous cells with the later
functions. But beware of the megaformula, it is very hard to debug.

HTH,
JP


On Nov 20, 9:44 am, SteveM wrote:
On Nov 20, 9:28 am, SteveM wrote:

This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.


Is there some sort of trick there? Outside in? Inside out?


Or some kind of editing tool?


Thanks.


SteveM


Sure, I mean trying to stuff multiple functions inside the formula
bar. e.g, INDEX(IF(MAX(MIN(BLAH(BLAH(BLAH

I know what the functions mean, it's the mechanics of building the
formulas that are frustrating.

SteveM


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Creating Complex Functions in the Worksheet Formula Bar - THIS ISNUTS!

Hey check out this page, it has a tutorial on building megaformulas.

http://j-walk.com/ss/excel/usertips/tip079.htm


HTH,
JP

On Nov 20, 9:44 am, SteveM wrote:
On Nov 20, 9:28 am, SteveM wrote:

This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.


Is there some sort of trick there? Outside in? Inside out?


Or some kind of editing tool?


Thanks.


SteveM


Sure, I mean trying to stuff multiple functions inside the formula
bar. e.g, INDEX(IF(MAX(MIN(BLAH(BLAH(BLAH

I know what the functions mean, it's the mechanics of building the
formulas that are frustrating.

SteveM




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Creating Complex Functions in the Worksheet Formula Bar - THIS

As soon as a worksheet function become complicated, I resort to VBA. I find
it very frustrating to debug worksheet functions that have multiple IF
stement.

It is much easy to document and debug a VBA function then a worksheet
function.

When I have to create a complex worksheet function, I do it in small pieces
(sometimes using multiple cells). Then when i get the peice working I
combine them into a larger function. I also use the worksheet menu Tools -
Formula Auditing - Evaluate Formula to help debug the formulas.

"SteveM" wrote:

On Nov 20, 9:28 am, SteveM wrote:
This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.

Is there some sort of trick there? Outside in? Inside out?

Or some kind of editing tool?

Thanks.

SteveM


Sure, I mean trying to stuff multiple functions inside the formula
bar. e.g, INDEX(IF(MAX(MIN(BLAH(BLAH(BLAH

I know what the functions mean, it's the mechanics of building the
formulas that are frustrating.

SteveM

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Creating Complex Functions in the Worksheet Formula Bar - THIS

On Nov 20, 9:53 am, Joel wrote:
As soon as a worksheet function become complicated, I resort to VBA. I find
it very frustrating to debug worksheet functions that have multiple IF
stement.

It is much easy to document and debug a VBA function then a worksheet
function.

When I have to create a complex worksheet function, I do it in small pieces
(sometimes using multiple cells). Then when i get the peice working I
combine them into a larger function. I also use the worksheet menu Tools -
Formula Auditing - Evaluate Formula to help debug the formulas.

"SteveM" wrote:
On Nov 20, 9:28 am, SteveM wrote:
This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.


Is there some sort of trick there? Outside in? Inside out?


Or some kind of editing tool?


Thanks.


SteveM


Sure, I mean trying to stuff multiple functions inside the formula
bar. e.g, INDEX(IF(MAX(MIN(BLAH(BLAH(BLAH


I know what the functions mean, it's the mechanics of building the
formulas that are frustrating.


SteveM


Thanks to you all for the advice.

I'll probably rely on the VB code approach.

I'm running 2003, so don't know what's in the current version. But
I'm surprised they have not built in a formula editor like the Query
editor in Access. But then again it's MS, so I'm not surprised.

SteveM
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 762
Default Creating Complex Functions in the Worksheet Formula Bar - THIS IS NUTS!

SteveM -

I suggest "inside out" and using worksheet cells for the "editing tool."

For your example, I would put the MIN function in a cell, the MAX function
in another cell with a reference to the cell containing the MIN, the IF
function in another cell with appropriate references, and finally, the INDEX
function in a fourth cell.

This approach facilitates debugging.

After everything is working fine, I might combine everything into a single
cell.

- Mike Middleton
http://www.DecisionToolworks.com
Decision Analysis Add-ins for Excel


"SteveM" wrote in message
...
On Nov 20, 9:28 am, SteveM wrote:
This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.

Is there some sort of trick there? Outside in? Inside out?

Or some kind of editing tool?

Thanks.

SteveM


Sure, I mean trying to stuff multiple functions inside the formula
bar. e.g, INDEX(IF(MAX(MIN(BLAH(BLAH(BLAH

I know what the functions mean, it's the mechanics of building the
formulas that are frustrating.

SteveM



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Creating Complex Functions in the Worksheet Formula Bar - THIS IS

Calling a function from a worksheet is simple. On the worksheet
=Myfunction(A1,B2,C3,D4:E7)

VBA
Function Myfunction(Num as Integer, Data as String, NewDate as Date, Target
as Range)

for each cell in Target
'your code
next cell
end Function
"SteveM" wrote:

This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.

Is there some sort of trick there? Outside in? Inside out?

Or some kind of editing tool?

Thanks.

SteveM

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Creating Complex Functions in the Worksheet Formula Bar - THIS IS

Interesting way round to come at Excel but it happens...

Inside out really. Here's an example of a nested If function (tends to
shock and amaze programmers!). Stick it in C2 and experiment with colours (a
really useful tool is Tools, Formula Auditing, Evaluate Formula):

=IF(AND(A2="Red",B2="Yellow"),"Orange",IF(OR(A2="S carlet",B2="Crimson"),"Red",IF(AND(OR(A2="Blue",A2 ="Navy"),B2="Yellow"),"Green","Some other colour")))

The Ands and Ors are read outwards before the Ifs are evaluated [syntax of IF:
IF(condition, if true, if false)]

Hope that helps in some way!

"SteveM" wrote:

This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.

Is there some sort of trick there? Outside in? Inside out?

Or some kind of editing tool?

Thanks.

SteveM



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Creating Complex Functions in the Worksheet Formula Bar - THIS

Isn't the code below easier to understand and debug and comment???

Function (Cell1 as Range, Cell2 as Range)
IF (Cell ="Red" and Cell2 ="Yellow") then
Mycolor = "Orange"
else
IF (cell1 ="Scarlet" or Cell2="Crimson") then
Mycolor = "Red"
else
IF (cell1="Blue" or cell1 ="Navy") and (cell2 ="Yellow") then
Mycolor = "Green"
else
Mycolor = "Some other color" 'I'm from the USA, don't spell colour
with a U
end if
end if
end if

end function


"Smallweed" wrote:

Interesting way round to come at Excel but it happens...

Inside out really. Here's an example of a nested If function (tends to
shock and amaze programmers!). Stick it in C2 and experiment with colours (a
really useful tool is Tools, Formula Auditing, Evaluate Formula):

=IF(AND(A2="Red",B2="Yellow"),"Orange",IF(OR(A2="S carlet",B2="Crimson"),"Red",IF(AND(OR(A2="Blue",A2 ="Navy"),B2="Yellow"),"Green","Some other colour")))

The Ands and Ors are read outwards before the Ifs are evaluated [syntax of IF:
IF(condition, if true, if false)]

Hope that helps in some way!

"SteveM" wrote:

This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.

Is there some sort of trick there? Outside in? Inside out?

Or some kind of editing tool?

Thanks.

SteveM

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Creating Complex Functions in the Worksheet Formula Bar - THIS

In Excel there are often multiple ways to do the same thing, some
easier than others. But if you don't understand the way functions
work, how are you going to write a VBA equivalent?

--JP


On Nov 20, 10:10 am, Joel wrote:
Isn't the code below easier to understand and debug and comment???

Function (Cell1 as Range, Cell2 as Range)
IF (Cell ="Red" and Cell2 ="Yellow") then
Mycolor = "Orange"
else
IF (cell1 ="Scarlet" or Cell2="Crimson") then
Mycolor = "Red"
else
IF (cell1="Blue" or cell1 ="Navy") and (cell2 ="Yellow") then
Mycolor = "Green"
else
Mycolor = "Some other color" 'I'm from the USA, don't spell colour
with a U
end if
end if
end if

end function


  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 256
Default Creating Complex Functions in the Worksheet Formula Bar - THIS ISNUTS!

I start by building the formula separately, each intermediate result
(what I consider intermediate) stored in its own cell. Next, I use
find/replace in a text editor to make it into one big formula.

Recently I wrote a macro to do this automatically. It takes a cell,
searches for any references to other cells, and if those cells contain
formulas, it brings them into one, resulting in a megaformula. Its
functionality is limited, but it works for most formulae that have
references on a single sheet and do not contain arrays.

Unless I know exactly what I'm doing, I rarely do everything in one
cell, through the formula bar.


On Nov 20, 9:28 am, SteveM wrote:
This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.

Is there some sort of trick there? Outside in? Inside out?

Or some kind of editing tool?

Thanks.

SteveM


  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default Creating Complex Functions in the Worksheet Formula Bar - THIS ISNUTS!

Can you post that macro?


Thx,
JP

On Nov 20, 3:18 pm, ilia wrote:
I start by building the formula separately, each intermediate result
(what I consider intermediate) stored in its own cell. Next, I use
find/replace in a text editor to make it into one big formula.

Recently I wrote a macro to do this automatically. It takes a cell,
searches for any references to other cells, and if those cells contain
formulas, it brings them into one, resulting in a megaformula. Its
functionality is limited, but it works for most formulae that have
references on a single sheet and do not contain arrays.

Unless I know exactly what I'm doing, I rarely do everything in one
cell, through the formula bar.

  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 256
Default Creating Complex Functions in the Worksheet Formula Bar - THIS ISNUTS!

It's a little long, so download it he
http://www.44lbs.net/ilia/mdlMakeMegaFormula.bas

Import the module into your personal macros workbook (File/Import
File).

Please read the comments at the top. Note that you must have a
reference to Microsoft VBScript Regular Expressions 1.0 in your VB
project (Tools/References). Because it's used often, I opted for
early binding. Modify isAddress() function if you wish to use late
binding - such as CreateObject("vbscript.RegExp").

I would appreciate any feedback as to the functionality, and/or
suggestions for modification. My contact information is also in the
comments at the top.


On Nov 20, 4:09 pm, JP wrote:
Can you post that macro?

Thx,
JP

On Nov 20, 3:18 pm, ilia wrote:



I start by building the formula separately, each intermediate result
(what I consider intermediate) stored in its own cell. Next, I use
find/replace in a text editor to make it into one big formula.


Recently I wrote a macro to do this automatically. It takes a cell,
searches for any references to other cells, and if those cells contain
formulas, it brings them into one, resulting in a megaformula. Its
functionality is limited, but it works for most formulae that have
references on a single sheet and do not contain arrays.


Unless I know exactly what I'm doing, I rarely do everything in one
cell, through the formula bar.- Hide quoted text -


- Show quoted text -




  #16   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Creating Complex Functions in the Worksheet Formula Bar - THIS IS NUTS!

Might only help a little, but remember you *can* embed newlines (Alt+Enter)
in your formula to break it up into workable chunks...

Tim


"SteveM" wrote in message
...
This may seem strange, but I code in VBA but never created complex
functions on a worksheet itself. Now it's driving me crazy trying to
embed functions in functions.

Is there some sort of trick there? Outside in? Inside out?

Or some kind of editing tool?

Thanks.

SteveM



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
Complex functions JP Ronse Excel Worksheet Functions 1 April 18th 10 06:23 PM
complex color fill conditions- if statements or complex formula? lilly8008 Excel Discussion (Misc queries) 1 December 18th 09 04:57 AM
RE-submitting of: constructing (complex) variables with worksheet functions broer konijn Excel Worksheet Functions 0 June 13th 06 11:36 AM
constructing (complex) variables with worksheet functions broer konijn Excel Discussion (Misc queries) 0 May 16th 06 10:55 PM
Performance tradeoffs of complex worksheet functions vs VBA? when to switch to a UDF? Keith R[_3_] Excel Programming 4 December 30th 03 09:47 AM


All times are GMT +1. The time now is 11:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"