Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Need Macro to Sum Range and Paste the Value into one Cell


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Need Macro to Sum Range and Paste the Value into one Cell


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Need Macro to Sum Range and Paste the Value into one Cell

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy range and paste into every 3rd cell of new range thomsonpa New Users to Excel 4 December 3rd 07 01:47 PM
Macro to copy, paste in a range and then delete Garry Excel Discussion (Misc queries) 0 March 23rd 06 07:37 PM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
Macro to Paste to a Variable Range - HELP Brandon - Excelinator Excel Programming 1 August 7th 04 10:04 PM
Macro to paste a copied range Ted[_7_] Excel Programming 2 December 26th 03 09:12 PM


All times are GMT +1. The time now is 10:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"