VBA Ismissing for a Range

MNpoker

Board Regular
Joined
Dec 15, 2003
Messages
154
Help on giving Optional Functions a value when they are a range and they are missing.


------------------------------------
ExponentialCDF(Weight As Range, Theta As Range, Optional Maximum As Range)

If IsMissing(maximum) then

------------------------------

Now if a maximum is not entered I want the maximum to be 999999999999 in all cases.

The number of cases would be identical to the number of (pieces?) in the Theta and Weight Ranges.

For example

ExponentailCDF(A1:b1,d1:d2)

This should produce
weight(1) = value in cell a1
weight(2) = value in cell b1

Theta(1) = value in cell d1
Theta(2) = value in cell d2

This part works fine and dandy (and if I enter in a range for the maximums it works fine as well). It's when I don't want to specify a maximum that it doesn't work in this case I'd want
Maximum(1) = 999999999999
Maximum(2) = 999999999999

I'll post some more of the actual code in the next post.
 
This doesn't even work
Tester(6) And either does Test(6,a1:a4) where a3 has a value

Public Function Tester(X, Optional Maximums As Range)

For AA = 1 To 4
Maximums(AA) = 999999999
Next AA

Tester = Maximums(3)

End Function
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Last bump I promise!!!

This is going to entail a huge amount of work if I can't get this figured out.
 
Upvote 0
That function failed on this line when I tried it.
Code:
Maximums(AA) = 999999999

There was no error message as functions just stop executing when they encounter an error and return the #VALUE error in the cell.
 
Upvote 0
Try this:

Code:
Public Function Tester(X, Optional Maximums As Range)
Dim maximum()
NumCurves = X
If Maximums Is Nothing Then
    ReDim maximum(NumCurves)
    For AA = 1 To NumCurves
        maximum(AA) = 999999999
    Next AA
End If
Tester = maximum(3)
End Function
 
Upvote 0
BINGO!!

Think that's it (Hotpeppers did not work when I included values in the maximums - but a minor change seemed to fix that.)

Code:
Public Function Tester(X, Optional Maximums As Range)
Dim maximum()
NumCurves = X
If Maximums Is Nothing Then
    ReDim maximum(NumCurves)
    For AA = 1 To NumCurves
        maximum(AA) = 999999999
    Next AA
Else
ReDim maximum(NumCurves)
    For AA = 1 To NumCurves
    maximum(AA) = Maximums(AA)
    Next AA
End If
Tester = maximum(3)
End Function

Thanks!!!

Crossing my fingers that is works globally.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,055
Latest member
excelhelp12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top