Sum of data accross columns in lastrow+1

Edwardvanschothorst

New Member
Joined
Sep 20, 2021
Messages
14
Office Version
  1. 365
Platform
  1. Windows
I am trying to add the value in the lastrow in columns C&D in lastrow +1. Can someone please help me with the formula on this? I know this is probably obviouse, but it is friday afternoon, and my brain is shot.

VBA Code:
LastPopulatedRow = Range("A" & Rows.Count).End(xlUp).Row
Cells(LastPopulatedRow + 1, 10) =
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Obtaining the last row in column C can be done like this
VBA Code:
LastPopulatedRow = Cells(Rows.Count, "C").End(xlUp).Row
 
Upvote 0
I have the value / link to the cell, I am trying to find the formula to put into the VBA script. The formula I have in J141 does give me the correct result, but there is a variable amount of rows, and the formula will not work if I just insert the formula.

linear stock production calc Final.xlsm
ABCDEFGHIJ
139A2X2X.25117733-122352.072$ 0.52X 235.
140A2X2X.25117733-122372.072$ 0.52X 237.
141X 239.
1D_1
Cell Formulas
RangeFormula
E139:E140E139=ROUNDUP((B$7+2)/COUNT(C$22:C$200)+C139+0.055,3)
F139:F140F139=(VLOOKUP(A139,STOCK!$A$3:$C$20,3,FALSE)/VLOOKUP(A139,STOCK!$A$3:$C$20,2,FALSE)*E139)
J139:J140J139="X "&D139&"."
J141J141="X " & SUM(C140:D140) & "."



VBA Code:
 columnincrementer = -1
    For i = 1 To Worksheets.Count
        cursheetname = Sheets(i).Name
        If Left(cursheetname, 3) = "1D_" And IsNumeric(Mid(cursheetname, 4, 1)) Then
            columnincrementer = columnincrementer + 1
        Sheets(cursheetname).Select
            LastPopulatedRow = Range("A" & Rows.Count).End(xlUp).Row
                If IsEmpty(Range("a23").Value) = False Then
                    Range("E22:j22").autofill Destination:=Range("E22:j" & LastPopulatedRow), Type:=xlFillDefault
                End If
            Cells(LastPopulatedRow + 1, 10) =
 
Upvote 0
Ok, how about ...

VBA Code:
    Const MyFormula As String = "=""X "" & SUM(C~:D~) & ""."""

    Cells(LastPopulatedRow + 1, 10) = VBA.Replace(MyFormula, "~", LastPopulatedRow)
 
Upvote 0
Solution
You are welcome and thanks for letting me know.
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,461
Members
449,085
Latest member
ExcelError

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