Reputation: 33
Here is my case
I have this code in my Macro : The code is Good, no need to change it.
Sheets("Water").Select
Cells.Select
Range("A2").Select
ActiveCell.Formula = "=SUM(D2:N2)+((COUNTIF(D2:N2,""GOLD"")+COUNTIF(D2:N2,""PLATIN""))*1)+((COUNTIF(D2:N2,""PLPLUS"")+COUNTIF(D2:N2,""AMBASS""))*2)"
Range("A2").AutoFill Destination:=Range("A2:A" & Cells(Rows.Count, 2).End(xlUp).Row)
LastRow = Range("A2").End(xlDown).Row
Cells(LastRow + 2, "A").Formula = "=SUM(A2:A" & LastRow & ")"
Dim LRowA As String, LRowB As String
LRowA = [A4200].End(xlUp).Address
Range("A:A").Interior.ColorIndex = xlNone
Range("A2:" & LRowA).Interior.ColorIndex = 33
Range("A:A").HorizontalAlignment = xlCenter
On this Code we are on Sheets "Water".
I have a formula and the Result Appear here in the sheet "Water":
Cells(LastRow + 2, "A").Formula = "=SUM(A2:A" & LastRow & ")"
Now I want that this result appear on Sheet "Download" in the cell M8.
Is it possible.....
Upvotes: 0
Views: 44
Reputation: 23081
Do you mean this? Have shortened your code a little too.
Sub x()
Dim LRowA As String, LRowB As String
With Sheets("Water")
.Range("A2:A" & .Cells(Rows.Count, 2).End(xlUp).Row).Formula = "=SUM(D2:N2)+((COUNTIF(D2:N2,""GOLD"")+COUNTIF(D2:N2,""PLATIN""))*1)+((COUNTIF(D2:N2,""PLPLUS"")+COUNTIF(D2:N2,""AMBASS""))*2)"
LastRow = .Range("A2").End(xlDown).Row
.Cells(LastRow + 2, "A").Formula = "=SUM(A2:A" & LastRow & ")"
LRowA = .Range("A4200").End(xlUp).Address
.Range("A:A").Interior.ColorIndex = xlNone
.Range("A2:" & LRowA).Interior.ColorIndex = 33
.Range("A:A").HorizontalAlignment = xlCenter
End With
Sheets("Download").Range("M8").Formula = "=""Bottle of water: "" & SUM(Water!A2:A" & LastRow & ")"
End Sub
Upvotes: 1