+ Reply to Thread
Results 1 to 2 of 2

Copy -> Paste Special -> Values (PROBLEM)

Hybrid View

davehunter Copy -> Paste Special ->... 10-04-2007, 08:15 AM
royUK This should copy the cells... 10-04-2007, 09:20 AM
  1. #1
    Registered User
    Join Date
    04-26-2007
    Posts
    94

    Copy -> Paste Special -> Values (PROBLEM)

    Hi Guys.

    I have a problem with a copy > paste special > values function I am using in a macro.

    I have a button that opens a popup to allow a user to select an excel file.

    The complete file is then copied using:

    Range("A1:IV65536").Copy
    It is then pasted into the other workbook using:

    ThisWorkbook.Activate
    Sheets("Sheet2").Activate
    Sheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _:=False, Transpose:=False
    The above code seems to be leaving formulas in my sheet, which then leads to a 'Type Mismatch' error.

    Is their something else I should be doing, or is there a way I can guarentee that no formulas are pasted?

    Thanks!
    Dave

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This should copy the cells containing formulas as values to the main workbook

     Dim curWb  As Workbook
        Dim tarWb  As Workbook
        'wb containing formulas, should be the active one
        Set curWb = ActiveWorkbook
        'wb to copy to, contains the code
        Set tarWb = ThisWorkbook
        curWb.ActiveSheet.Cells.Copy
        tarWb.Sheets(1).Cells(1, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                                                                                          :=False, Transpose:=False
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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