# More VBA: Getting smaller ranges from bigger ones.

#### MNpoker

##### Board Regular
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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

#### MNpoker

##### Board Regular
Bump

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

thanks!!

Getting there.

Replies
59
Views
1K
Replies
9
Views
251
Replies
2
Views
473
Replies
0
Views
614
Replies
1
Views
380

1,195,936
Messages
6,012,390
Members
441,695
Latest member
MickRobertson

### 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.

### Which adblocker are you using?

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

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