# Cell Range as function Parameter.

#### imtiaztariq

##### New Member
Hi guys,

I want to pass a Range of cells which needs to be given via prompt box into the following formula but I dont know how to do this.

This is the formula I have placed in my Excel sheet cell and I am reffering to this range in many other cells so What i need is that the user selects its range and it is placed it in every cell that contains this list.

=INDEX(LINEST('Regression Input Data'!\$N\$5:\$N\$19,'Regression Input Data'!\$M\$5:\$M\$19,1,1),5,1)

Last edited:

### Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
What might be easier is if you define a named range which you can then include in all the relevant formulas. Then if the definition of this range is altered, all the formulas using it will alter too. Well, they'll still look the same, but give different results.

Can you please let me know how to pass a range name into this funtion and when needed to change how would it be.

thanks

If you know how to prompt a user for the range and place its address in A1 you can use:

=INDEX(LINEST(INDIRECT(A1),'Regression Input Data'!\$M\$5:\$M\$19,1,1),5,1)

I have tried this thing now every thing seems to be working good here but the formula still does not work. WHere could be the error.

Dim InputCells As Excel.Range
Dim OutputCells As Excel.Range
On Error Resume Next
'Show input box to get range of cells that want to copy

Set InputCells = _
Application.InputBox(Prompt:="Block input cells/range", _
Title:="Copy Paste", Type:=8)

Set OutputCells = _
Application.InputBox(Prompt:="Select cell where you want paste it", _
Title:="Copy Paste", Type:=8)

ssr = Application.WorksheetFunction.Index(Application.WorksheetFunction.LinEst(InputCells, outputcelss, 1, 1), 4, 2)
Cells(1, 1).Value = ssr

a = Application.WorksheetFunction.Index(Application.WorksheetFunction.LinEst(InputCells, outputcelss, 1, 1), 2, 2)
Cells(2, 1).Value = a

There's a typo here:

ssr = Application.WorksheetFunction.Index(Application.WorksheetFunction.LinEst(InputCells, outputcelss, 1, 1), 4, 2)

To avoid such errors you should put Option Explicit at the top of your module.

Yeah that was the reason I figured it out thanks for your help

Replies
1
Views
629
Replies
1
Views
588
Replies
8
Views
330
Replies
3
Views
103
Replies
0
Views
266

1,218,842
Messages
6,144,796
Members
450,567
Latest member
Mplz

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