More VBA: Getting smaller ranges from bigger ones.

MNpoker

Board Regular
Joined
Dec 15, 2003
Messages
154
This is from a Public Function.

Say I have an Range A1:D7 -- This defines all the information I need.

Now I want To Create new ranges where
Range(1) = B1:D1
Range(2) = B2:D4
Range(3) = B3:C3
.
.
.
Range(7) = B7:D7

*Note the new ranges do not include the first column of the 'big' range.
The Range(X) is the Curve(X) values below.

The New ranges are the inputs required for Public functions that have been created.

I am this far: (Though I may be on a bad track)

Public Function MCurvePDF(X, DefineMCurve As Range)

' To get the PDF of a mixed curve at X we add the PDF's of each individual curve

'Set up the curves that go into the mixed curves
NumCurves = DefineMCurve.Rows.Count
Dim Curve(NumCurves) As Range

LengthOfMCurve = DefineMCurve.Columns.Count

' Get the Individual Curve Arrays
For A1 = 1 To NumCurves
For B1 = 2 To LengthOfMCurve

????????????


Thanks!!

P.S. Does anyone know a good source for learning this stuff? Prefer a self-help book that is also usefull reference guide.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Bump :banghead:

Why does this work

Public Function MCurvePDF(X, DefineMCurve As Range)

' To get the PDF of a mixed curve at X we add the PDF's of each individual curve
' Allows up to 1000 Single Curves

Dim PDF(1000)

'Set up the curves that go into the mixed curves
NumCurves = DefineMCurve.Rows.Count
LOFMCurve = DefineMCurve.Columns.Count

' Get the Individual Curve Arrays
For A1 = 1 To NumCurves
For B1 = 3 To LOFMCurve
A = DefineMCurve.Cells(A1, B1)
Next B1
Next A1

MCurvePDF = A


But this doesn't (it gives a value error.)

Public Function MCurvePDF(X, DefineMCurve As Range)

' To get the PDF of a mixed curve at X we add the PDF's of each individual curve
' Allows up to 1000 Single Curves
Dim A As Range <-- ONLY DIFFERENCE
Dim PDF(1000)

'Set up the curves that go into the mixed curves
NumCurves = DefineMCurve.Rows.Count
LOFMCurve = DefineMCurve.Columns.Count

' Get the Individual Curve Arrays
For A1 = 1 To NumCurves
For B1 = 3 To LOFMCurve
A = DefineMCurve.Cells(A1, B1)
Next B1
Next A1


MCurvePDF = A
 
Upvote 0

Forum statistics

Threads
1,224,271
Messages
6,177,608
Members
452,785
Latest member
3110vba

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