+ Reply to Thread
Results 1 to 4 of 4

Thread: Macro Paste Special

  1. #1
    Registered User
    Join Date
    09-16-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    38

    Macro Paste Special

    Hey guys,

    I've got a sheet which has two column headings - Resources and Cost

    I have another sheet which has the calculations for both of these. They are in cells H24 and D29 of the second sheet.

    I want to have a macro on the second sheet that if I click it, it will paste special these two figures (values only so no formulae), into the active cell on the first sheet.

    This is the code I've got so far but every time I run the macro it just pastes into the same two cells in the first sheet and I have no idea how to change this.
    Sub ResourcePaste()
    '
    ' ResourcePaste Macro
    ' Macro recorded 16/09/2009 by nujwaan
    
    '
    
    '
        Sheets("Resource Cost Calculator").Select
        Range("D29").Select
        Selection.Copy
        Sheets("Input Form").Select
        Range("N8", "N32").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Resource Cost Calculator").Select
        Range("H24").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Input Form").Select
        Range("O8", "O32").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
    End Sub
    Please help! I hate VBA!
    Last edited by nujwaan; 09-17-2009 at 09:54 AM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Macro Paste Special

    Hello nujwaan,

    Welocme to the Forum!

    To make your posts easier to read, copy, and edit please wrap your code. I did it for you this time. Here is how you can do it next time.

    How to wrap your Code
    1. Select all your code using the mouse.
    2. Click on the # icon on the toolbar in the Message window. This will automatically wrap the text you selected with the proper Code tags to create a Code Window in your post.

    Use the Bulletin Board Code Tags
    [code] at the start of the first line,
    [/code] at the end of the last line.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    09-11-2009
    Location
    Nevada, USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Macro Paste Special

    Hi nujwaan,

    I am not clear on which part of the macro you are having trouble with. Is the paste special not working? Or is it that it is not pasting into all of the cells that you need?

    Rather than using pastespecial, try something like this instead:

    Sub ResourcePaste()
    
        Sheets("Resource Cost Calculator").Select
        myVal = Range("D29").Value
    
        Sheets("Input Form").Select    
        Range("N8").Value = myVal 
        Range("N32").Value = myVal
        Range("O8").Value = myVal
        Range("O32").Value = myVal
    
    
    End Sub

  4. #4
    Registered User
    Join Date
    09-16-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Macro Paste Special

    Hi rainlm,

    Sorry should have been more specific.

    What I want to do is create a macro so if I click on Sheet one in cell N8 and click the macro button in Sheet 2, two figures from Sheet 2 (in cells D29 and H24) will be populated in N8 and O8.

    Then if I click in N9 and run the macro again I want it to paste again in N9 and O9 and so on.

    The problem is that it is not the same data that is being posted each time. The second sheet is a calculator of costs and so I want to be able to input values in it and then have the user click a button to transfer those figures into the first sheet.

    Is that more clear?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0