Consulting

Results 1 to 3 of 3

Thread: Paste Values

  1. #1
    VBAX Regular
    Joined
    Apr 2011
    Posts
    25
    Location

    Paste Values

    I thought this would paste values only, but for some reason it's pasting my formulas. How can this macro be edited to copy and paste values?

    Thanks

    [vba]Sub NewUploadFile()
    Dim wb As Workbook
    Set wb = Workbooks.Add
    'copy and paste
    ThisWorkbook.Worksheets(1).Range("B1:P2000").Copy _
    Destination:=wb.Sheets("Sheet1").Range("A1")
    wb.Sheets("Sheet1").Columns.AutoFit
    Set wb = Nothing
    End Sub[/vba]

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    This should be what you need:[VBA]Sub NewUploadFile()
    Dim wb As Workbook
    Set wb = Workbooks.Add
    'copy and paste
    ThisWorkbook.Worksheets(1).Range("B1:P2000").Copy
    wb.Sheets("Sheet1").Range("A1").PasteSpecial Paste:=xlPasteValues
    wb.Sheets("Sheet1").Columns.AutoFit
    Set wb = Nothing
    End Sub[/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Regular
    Joined
    Apr 2011
    Posts
    25
    Location
    Perfect....thanks!

Posting Permissions

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