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 Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

gnaga

Well-known Member
Joined
Jul 9, 2002
Messages
700
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
I am using like this

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

it works

GNaga
 

Paultje

New Member
Joined
Sep 17, 2002
Messages
2
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
 

Forum statistics

Threads
1,148,194
Messages
5,745,276
Members
423,942
Latest member
excelhelp1423

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