+ Reply to Thread
Results 1 to 3 of 3

Paste Special (Addition) without affecting Subtotals (VBA)

Hybrid View

Paul Cherian Paste Special (Addition)... 03-01-2015, 01:33 AM
AlphaFrog Re: Paste Special (Addition)... 03-01-2015, 03:16 AM
Paul Cherian Re: Paste Special (Addition)... 03-01-2015, 03:39 AM
  1. #1
    Registered User
    Join Date
    02-23-2014
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    73

    Paste Special (Addition) without affecting Subtotals (VBA)

    Dear VBA Experts!

    I am trying to create a vba macro that can copy values from a specific range and paste special (add) to the values in another range without changing the subtotals in the target column. But something somewhere went wrong. Could you please help me in this regards to debug the issue.
    Here is the code which I did.

    Sub copypasteaddvalues()
    Dim ws As Worksheet
    For Each ws In ThisWorkbook.Worksheets
    If ws.Name <> "*Conso" Or ws.Name <> "Sheet*" Or ws.Name <> "Graph*" Or ws.Name <> "Data*" Then _
     Range("H15:H50").Copy
    Range("F15").PasteSpecial Paste:=xlPasteValues, _
        operation:=xlAdd, skipblanks:=False
    Next ws
    End Sub
    Last edited by Paul Cherian; 03-01-2015 at 01:39 AM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Paste Special (Addition) without affecting Subtotals (VBA)

    Sub copypasteaddvalues()
        Dim ws As Worksheet
        For Each ws In ThisWorkbook.Worksheets
            If Not ws.Name Like "*Conso" And _
               Not ws.Name Like "Sheet*" And _
               Not ws.Name Like "Graph*" And _
               Not ws.Name Like "Data*" Then
                    ws.Range("H15:H50").Copy
                    ws.Range("F15").PasteSpecial Paste:=xlPasteValues, _
                            Operation:=xlAdd, Skipblanks:=False
            End If
        Next ws
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    02-23-2014
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: Paste Special (Addition) without affecting Subtotals (VBA)

    Hey Alpha!!

    Thanks a lot. Its working Well!!

    Only the formula for the sub totals are coming like this =((SUM(F15:F18))+0)+0

    But its fine with me .

    thanks a lot for your kind help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Addition to code to copy and pastes special values and cell format, but not links.
    By singerbatfink in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2014, 03:10 PM
  2. copy formula and paste for new data added and autofill.....and paste special values
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-13-2014, 07:40 AM
  3. [SOLVED] how can I paste text using paste special, without clicking paste button?
    By Exxcel Noob in forum Excel General
    Replies: 6
    Last Post: 05-14-2012, 08:21 PM
  4. Replies: 1
    Last Post: 06-20-2005, 07:05 PM
  5. When using subtotals, how do I copy and paste only the subtotals .
    By Wendy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-13-2005, 06:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1