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

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.
 
Upvote 0
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
 
Upvote 0
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)
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

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