Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Home Made Conditional Functions

Hi

Im trying to figure out how to do a pretty basic operation with VBA.
Let say we have a spread sheet with the range A1:A4 that contain a 1 or
a 2, and a range B1:B4 containg any number. What I need to do is this:
If the number in a cell in row A =1 add the number in the B row of the
same column with any others that meet the critieria.

I will show the nested function that accomplishes this task for
clarification: "{=sum(if(A1:A3=1,B1:B3))}"

the reason I can't use the nested function is that this is but a small
portion of a very big operation im trying create.

Here is what I have in VBA, the thing I don't understand is how to make
it add up the numbers under number that meet the criteria:

Function Maybe(A As Range, B As Range)

Dim K As Integer

For Each A In A

If A = 1 Then
K = K + B?????????
End If
Next

Maybe = K

End Function


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Home Made Conditional Functions

Can you use

=SUMIF(A1:A4,1,B1:B4)

???

In article ,
ksnapp wrote:

Hi

Im trying to figure out how to do a pretty basic operation with VBA.
Let say we have a spread sheet with the range A1:A4 that contain a 1 or
a 2, and a range B1:B4 containg any number. What I need to do is this:
If the number in a cell in row A =1 add the number in the B row of the
same column with any others that meet the critieria.

I will show the nested function that accomplishes this task for
clarification: "{=sum(if(A1:A3=1,B1:B3))}"

the reason I can't use the nested function is that this is but a small
portion of a very big operation im trying create.

Here is what I have in VBA, the thing I don't understand is how to make
it add up the numbers under number that meet the criteria:

Function Maybe(A As Range, B As Range)

Dim K As Integer

For Each A In A

If A = 1 Then
K = K + B?????????
End If
Next

Maybe = K

End Function


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Home Made Conditional Functions

The problem with using sumif is that this is only a small part of wha
is very big nested function. The issue shown is the part I can'
figure out on my own

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Home Made Conditional Functions

You can't nest UDFs deeper than 7 either, so making the function a UDF
won't help you.

Perhaps if you gave some idea of what your big nested function involved
someone could help find a better solution...

In article ,
ksnapp wrote:

The problem with using sumif is that this is only a small part of what
is very big nested function. The issue shown is the part I can't
figure out on my own.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Home Made Conditional Functions

The end product of my nested function is this, Here is a version of i
without specific cell refrences"

"{=Normin([CELL REFERENCE THAT CONTAINS THE PROBABILITY IM LOOKIN
FOR],Average(if([ROW REFFERENCE THAT CONTAINS DAY NUMBERS]=[CEL
REFFERENCE THAT CONTAINS THE DAY NUMBER IM LOOKING FOR],[ROW REFFERENC
THAT CONTAINS THE ACTUAL DATA I WANT ANALYZED])),Stdev((if([RO
REFFERENCE THAT CONTAINS DAY NUMBERS]=[CELL REFFERENCE THAT CONTAIN
THE DAY NUMBER IM LOOKING FOR],[ROW REFFERENCE THAT CONTAINS THE ACTUA
DATA I WANT ANALYZED])))}"


Or this may be easier on the eyes:

"{=Norminv(A1, average(if(B:B=A2,C:C)),Stdev(if(B:B=A2,C:C)))}"

where A1 contains a probability, A2 contains a day number (1-7), wher
B:B countains a bunch of day numbers, and C:C countains the actua
numbers to crunch.

The reason I want a UDF so bad is that all of the cell refrences are t
a different workbook and entering this formula for 126 different set
of data is tedious and error prone, even with all the pastin
techniques that usually take the work out of my day.


Let me extend my thanks to everybody who has commented on my problem.

thank yo

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Home Made Conditional Functions

I may be misunderstanding your situation, but it sounds to me that
instead of a UDF, you're more in need of defining range names. For
instance:

Choose Insert/Name/Define

Name in workbook Refers to:
p_1 [Workbook2.xls]Sheet1!A1
daynumber1 [Workbook2.xls]Sheet1!A2
daynumbers [Workbook2.xls]Sheet1!B:B
crunch [Workbook2.xls]Sheet1!C:C

then your formula becomes:

{=NormInv(p_1, AVERAGE(IF(daynumbers = daynumber1, crunch),
STDEV(IF(daynumbers = daynumber1, crunch))}






In article ,
ksnapp wrote:

The reason I want a UDF so bad is that all of the cell refrences are to
a different workbook and entering this formula for 126 different sets
of data is tedious and error prone, even with all the pasting
techniques that usually take the work out of my day.

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
Multiple functions, conditional functions HeatherBelle Excel Worksheet Functions 7 October 17th 08 03:57 PM
Problems with functions made in different languagues Berbel Excel Discussion (Misc queries) 3 May 2nd 07 03:04 PM
Shortcut keys: CNTRL+HOME vs. HOME Paul Ofthewild Excel Discussion (Misc queries) 1 November 24th 05 09:29 PM
conditional functions j Excel Worksheet Functions 2 December 10th 04 02:55 PM
conditional functions juliafw Excel Worksheet Functions 1 December 9th 04 05:19 PM


All times are GMT +1. The time now is 04:20 AM.

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"