+ Reply to Thread
Results 1 to 7 of 7

simple macro -- looking to paste values, not formulas

Hybrid View

  1. #1
    Registered User
    Join Date
    04-10-2014
    Location
    Miami, FL
    MS-Off Ver
    Excel 2010
    Posts
    3

    Talking simple macro -- looking to paste values, not formulas

    Hey guys, first post here. Just started working at a bank, and some help writing a macro that consolidates data from various worksheets into one. I've written it already and it works well:

    Sub Consolidate()
    Dim ws As Worksheet
    For Each ws In Sheets
    If ws.Name <> "Country Name" Then
    ws.Range("A3:t64").Copy Destination:= _
    Sheets("Country Name").Range("A" & Rows.Count). _
    End(xlUp).Offset(1)
    End If
    Next ws
    End Sub


    The issue is that I want to only grab the values, not formulas. I understand that I should be using some variant of:

    Selection.PasteSpecial Paste:=xlPasteValues


    I just don't know how to actually integrate this into my previous macro. Any suggestions?

    Thanks.

  2. #2
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: simple macro -- looking to paste values, not formulas

    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: simple macro -- looking to paste values, not formulas

    Sub Consolidate()
    Dim ws As Worksheet
    Application.ScreenUpdating = False
    For Each ws In Sheets
    If ws.Name <> "Country Name" Then
    ws.Range("A3:t64").Copy
    Sheets("Country Name").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial (xlPasteValues)
    End If
    Next ws
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    End Sub

  4. #4
    Registered User
    Join Date
    04-10-2014
    Location
    Miami, FL
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: simple macro -- looking to paste values, not formulas

    Perfect, thank you for the help.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: simple macro -- looking to paste values, not formulas

    Please use Code Tags when posting. See Forum Rule No. 3.

    Maybe:

    Sub clout90265()
    Dim ws As Worksheet
    For Each ws In Sheets
    If ws.Name <> "Country Name" Then
    Sheets("Country Name").Range("A" & Rows.count).End(3)(3).Resize(64, 20).Value = ws.Range("A3:T64").Value
    Sheets("Country Name").Rows(Range("A" & Rows.count).End(3)(0).Row & ":" & Range("A" & Rows.count).End(3)(1).Row).Clear
    End If
    Next ws
    End Sub

  6. #6
    Registered User
    Join Date
    04-10-2014
    Location
    Miami, FL
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: simple macro -- looking to paste values, not formulas

    OK, will do in the future. Thanks for the heads up.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: simple macro -- looking to paste values, not formulas

    If you are satisfied with the solutions provided, Please mark this thread as solved. See Forum Rule No. 9.


    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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. how to get a simple macro to copy and paste values only
    By sumesh56 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2014, 11:03 PM
  2. Macro to paste formulas, but not values
    By simple? in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-27-2013, 03:14 PM
  3. [SOLVED] Macro to paste formulas then paste values
    By deanstein in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-19-2013, 11:30 AM
  4. [SOLVED] simple macro help - paste values
    By kamelkid2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-18-2012, 11:13 AM
  5. Macro to Copy Paste Values and Formulas
    By thillis in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-19-2009, 11:55 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