I have a code that is to calculate the sum between two cells and then copy this result to another sheet, I would like the result to stay in f70 and then copy from there . But below code isnt work its put at 0 on input_6
wbMe.Sheets("blank3").Range("F70") = WorksheetFunction.Sum(Range("F68:G68"))
wbMe.Sheets("blank3").Range("F70").Copy
wbMe.Sheets("input_6").Cells(3, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial Paste:=xlPasteValues
CodePudding user response:
You don't have to use copy/paste in this case.
Also, make sure to qualify ALL of your references - in particular, the Range("F68:G68")
refers to the currently active sheet, which may not be the one you want.
This code example hopefully shows you how to get what you want:
Option Explicit
Sub test()
Dim wbMe As Workbook
Dim b3 As Worksheet
Dim in6 As Worksheet
Set wbMe = ThisWorkbook
Set b3 = wbMe.Sheets("blank3")
Set in6 = wbMe.Sheets("input_6")
b3.Range("F70").Value = WorksheetFunction.Sum(.Range("F68:G68"))
Dim lastCol As Long
lastCol = in6.Cells(3, in6.Columns.Count).End(xlToLeft)
in6.Cells(3, lastCol).Value = b3.Range("F70").Value
End Sub