Cell Range as function Parameter.

imtiaztariq

New Member
Joined
Jul 22, 2010
Messages
4
Hi guys,

I am stuck in completing this task. It might be very simple but I am not good at VBA so please help.

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)

Would really appriciate your help thanks in advance
 
Last edited:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Weaver

Well-known Member
Joined
Sep 10, 2008
Messages
5,196
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.
 

imtiaztariq

New Member
Joined
Jul 22, 2010
Messages
4
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
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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)
 

imtiaztariq

New Member
Joined
Jul 22, 2010
Messages
4

ADVERTISEMENT

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
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,615
Messages
5,832,712
Members
430,156
Latest member
Amosjack1

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
Top