Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Can anyone help with the Excel VB syntax to sum a range and paste the value into one cell. The following code is not working for me: Sheets("Sheet1").sum(Range("F36:f45")) Range("e88").Offset(X, 0).Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Note: the above syntax is in a loop. Thus, the need for Offset(x, 0) |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Dim myTotal as double mytotal = application.sum(worksheets("sheet1").range("f36:f4 5")) worksheets("sheetnamehere").range("e88").offset(x, 0).value = mytotal I'm not sure how the loop fits in. Mike wrote: Can anyone help with the Excel VB syntax to sum a range and paste the value into one cell. The following code is not working for me: Sheets("Sheet1").sum(Range("F36:f45")) Range("e88").Offset(X, 0).Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Note: the above syntax is in a loop. Thus, the need for Offset(x, 0) -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You don't have to copy & paste special in this case; you can just assign the
sum of the range to the specified cell. Here are two versions: Sheets("Sheet1").Range("F36:F45").Select Range("E88").Offset(x, 0).Value = Application.WorksheetFunction.Sum(Selection) Range("E88").Offset(x, 0).Value = _ Application.WorksheetFunction.Sum(Sheets("Sheet1") .Range("F36:F45")) Unless you change the 36:F45 range each time, you are going to put the same total in a destination cell with every loop. Hope this helps, Hutch "Mike" wrote: Can anyone help with the Excel VB syntax to sum a range and paste the value into one cell. The following code is not working for me: Sheets("Sheet1").sum(Range("F36:f45")) Range("e88").Offset(X, 0).Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Note: the above syntax is in a loop. Thus, the need for Offset(x, 0) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
copy range and paste into every 3rd cell of new range | New Users to Excel | |||
Macro to copy, paste in a range and then delete | Excel Discussion (Misc queries) | |||
Copy and Paste macro needs to paste to a changing cell reference | Excel Programming | |||
Macro to Paste to a Variable Range - HELP | Excel Programming | |||
Macro to paste a copied range | Excel Programming |