Building code.. Count... formula

buzz71023

Active Member
Joined
May 29, 2011
Messages
295
Office Version
  1. 2016
Platform
  1. Windows
I am struggling getting a code built that will count all the data point from L3 down then paste formula =ABS(L4-L3) from cell V4 down to the same row as the last data point in L. (If V4 = ABS(L4-L3) then V5 = ABS(L5-L4) and so on till the last data point row)

If it helps, I already have the data points counted as they are entered. E20 has the total number entered for that column.

Everything I have tried has failed badly. Any suggestions/help is much appreciated.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
This was my latest attempt....


Code:
Sub Complete_Click()
Dim LROW As Single, DATAPTS As Integer

Range("M10").Select

DATAPTS = Range("E20")

    LROW = Selection.End(xlDown).Row

LASTROW = LROW

FILLPTS = DATAPTS + 2

FILLER = FILLPTS

[V4] = "=ABS(M11-M10)"

Range("V4").Copy

Range("V5:V" + FILLER).PasteSpecial

End Sub
 
Upvote 0
Maybe
Code:
Sub MM1()
Range("V4:V" & Cells(Rows.Count, "L").End(xlUp).Row).Formula = "=ABS(L4-L3)"
End Sub
 
Upvote 0
I'm not sure that I completely understand your requirement but the following, even if it doesn't solve the problem, should point you on the right path.

Code:
Sub Complete_Click()
Dim LROW As Single
LROW = Range("M10").End(xlDown).Row
Range("V4").Formula = "=ABS(M11-M10)"
Range("V4").Resize(LROW - 10, 1).FillDown
End Sub
 
Upvote 0
Thanks,
i had a mistype in my most recent post but I adjusted and both seem to work well.
Thanks you both again for the replies
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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