How do i use mac to place formula into sheet that use vb ref

DevintheDude

Board Regular
Joined
Jun 8, 2007
Messages
153
lastcell = Cells(Rows.Count, 1).End(xlUp).row
last = lastcell + 1
Cells(last, "R").Formula = "=SUM(""R4:R""& last)"


I have the formula above the only problem with it is that it puts the formula as is last's value is not being used like i want it to is their another way or how can i make last the value first before it sends to the sheet
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
This isn't specific to a Mac.

It looks like you have data in column R and would like a formula summing everything in that column (below row 3) placed at the end of the column.
If so, this should do it

Code:
Dim xRange As Range

Set xRange = Cells(.Rows.Count, 18).End(xlUp)
xRange.Offset(1, 0).FormulaR1C1 = "=SUM(R4C:R[-1]C)"
 
Upvote 0
No this is not specific to a MAC, mac in the quesiton stands for macro if i wrote it out it wouldn't fit.

But yeah that examples work just perfect how does R[-1] know to go to the last cell
why do you offset row 1 col 1 what does that do other than that i understand
 
Upvote 0
R[-1] is R1C1 notation for "this row minus 1".
The variable xRange is set to the last filled cell in the column (at the time that that line is excicuted.) . I want the formula put one cell below that, so I Offset(1,0).

And yes, the code can be modified to do columns as well as cells.
 
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

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