+ Reply to Thread
Results 1 to 9 of 9

Copy / Paste Special Values Script

  1. #1
    Registered User
    Join Date
    04-28-2008
    Posts
    36

    Red face Copy / Paste Special Values Script

    Hi All

    My command button is on a different worksheet to where the copy/paste needs to occur. I originally had the command button on the same worksheet with the following code:

    Private Sub CommandButton9_Click()

    Sheets("summary").Select
    Range("CH45:CH61").Select
    Selection.Copy
    Range("CG45:CG61").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Range("CH73:CH78").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("CG73:CG78").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Range("CH82:CH96").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("CG82:CG96").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Range("CH112:CH119").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("CG112:CG119").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Range("CH124:CH136").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("CG124:CG136").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Range("CH140:CH151").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("CG140:CG151").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    End Sub
    now that i have moved the command button to a different sheet, and tried to cut the above code into the private sub command of the new sheet (sorry if my language is not correct), it does not work...

    what should i be doing different to make it work?

    Jason

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Copy / Paste Special Values Script

    Are you getting any error messages?

    If you are, What are they & what command does the errore refer to?
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    04-28-2008
    Posts
    36

    Re: Copy / Paste Special Values Script

    there are no error messages, it just does nothing...

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Copy / Paste Special Values Script

    Can you able to post a copy of the workbook

  5. #5
    Registered User
    Join Date
    04-28-2008
    Posts
    36

    Re: Copy / Paste Special Values Script

    its very sensitive information as it is a sales forecast and financial outlook....is there any other way to do this?

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Copy / Paste Special Values Script

    Without any error messages or seeing the workbook I would be totally guessing.

    In theory if it worked when it was on 1 sheet it should still work when placed n another sheet.

    Regardless of what sheet the button is on the code should run and on the Summary sheet - which is the sheet selected by the 1st command of the macro

  7. #7
    Registered User
    Join Date
    04-28-2008
    Posts
    36

    Re: Copy / Paste Special Values Script

    ok sorry, but i do get an error: runtime error 1004, Select method of range class failed...after debugging it stops on the second line of code (range)

  8. #8
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Copy / Paste Special Values Script

    That error message helps

    You do not need to select sheets or ranges of cells
    Try replacing your code with this
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-28-2008
    Posts
    36

    Re: Copy / Paste Special Values Script

    change works perfectly...every so greatful mud!!

+ 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