How to put a selected range into a formula

Paultje

New Member
Joined
Sep 17, 2002
Messages
2
I want to write a macro that puts two selections the user made before starting the macro into a formula
Like selections a1:a5 and b1:b5

the macro should fill c1 with
slope(a1:a5;b1:b5)
i can't get this to work with range("c1").formula=

Anyone any idea ?

Paul
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I am using like this

Range("C1").Value = "=Slope(A1:A5,B1:B5)"

it works

GNaga
 
Upvote 0
probably i didn't make myself clear.

what i want is this:
the user selectes 2 ranges and starts the macro

the macro puts the two selected ranges in two variabel, which are declared as ranges ,with

sel1=application.selection.Item(x)

then the macro should make the formula in cell c1 like =slope(sel1;sel2) where sel1 and sel2 are replaced with the ranges they contain

= "=Slope(A1:A5,B1:B5)"

Paul
 
Upvote 0

Forum statistics

Threads
1,214,870
Messages
6,122,021
Members
449,060
Latest member
LinusJE

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