+ Reply to Thread
Results 1 to 2 of 2

How to use paste special values

Hybrid View

  1. #1
    Registered User
    Join Date
    01-08-2019
    Location
    California, USA
    MS-Off Ver
    2016
    Posts
    2

    How to use paste special values

    Hi there,

    I am trying to create a summary column A on Sheet1 that takes column E from sheets 2-8 and forms one master list. Column E is a concatenation and the number of rows in column E differs from sheet to sheet, from month to month.

    I thought I was doing great until I ran into an issue with pasting as a special value. My understanding is I have to use pasting as a special value with a range, but I don't understand how I can make the range dynamic.

    This is where I got before I discovered the paste as special value issue (I practiced on a values only workbook).

    Thanks for your help!

    Private Sub CommandButton1_Click()
    Dim lastrow As Long, endrow As Long
    lastrow = Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
    For i = 2 To lastrow
    Worksheets("Sheet2").Cells(i, 5).Copy
    endrow = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
    Worksheets("Sheet2").Paste Destination:=Worksheets("Sheet1").Cells(endrow + 1, 1)
    Next i
    
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    02-06-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    373

    Re: How to use paste special values

    Hey,

    There is actually a separate pastespecial function in Excel, here is how that would look

    Sub PasteSpecial_Test()
    
        Dim ws As Worksheet
        Set ws = ThisWorkbook.Sheets("Sheet1")
        
        ws.Range("A1").Copy
        ws.Range("A1").PasteSpecial (xlPasteValues)
    
    End Sub
    Alternatively, you can actually set the value of the cell/range to it's own value to accomplish the same thing

    Sub Alternate_Set_as_Value()
    
        Dim ws As Worksheet
        Set ws = ThisWorkbook.Sheets("Sheet1")
        
        ws.Range("A1").Value = ws.Range("A1").Value
    
    End Sub

+ 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. 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
  2. force paste comands to paste>special>values
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-08-2013, 09:04 AM
  3. Replies: 1
    Last Post: 12-05-2012, 11:37 AM
  4. [SOLVED] Excel 2002 - Can only paste values, wont let me paste special
    By MK_Chopper_P in forum Excel General
    Replies: 2
    Last Post: 07-12-2012, 02:22 AM
  5. Replies: 2
    Last Post: 04-12-2011, 09:46 PM
  6. Macro to special paste dynamic values into text values with periods
    By iyudhi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-01-2011, 04:42 PM
  7. Paste Special Values-when I paste into the last book
    By christopherj79 in forum Excel General
    Replies: 1
    Last Post: 01-15-2009, 12:03 PM

Tags for this Thread

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