+ Reply to Thread
Results 1 to 6 of 6

Thread: Copy and Paste Using a Macro

  1. #1
    Registered User
    Join Date
    12-12-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    18

    Copy and Paste Using a Macro

    Need help on a macro to copy and paste from a table in a sheet called "Days" (column J) to a table in a sheet called "Weeks" Column "B"

    My problem is Column "J" on the days sheet contains a formula and I only want to copy the data not the formula to the "Weeks" sheet column "B"

    Look forward to some help.

    Cheers
    Malawimick
    Attached Files Attached Files
    Last edited by malawimick; 01-10-2012 at 03:48 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-09-2010
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    346

    Re: Copy and Paste Using a Macro

    Hi

    you need to use the "paste values" option in paste special

    this macro will copy the values from cells J2:J100 in sheet "days" to cell B2 in sheet "weeks":

    Sub paste_values()
        Sheets("Days").Range("j2:j100").Copy
        Sheets("Weeks").Select
        Range("B2").Select
        Selection.PasteSpecial Paste:=xlPasteValues
    End Sub
    Assuming you want to paste this week's data in the column after last week's data in sheet "weeks", this macro will paste the values from J2:J100 in the first empy cell to the right of cell A2 in sheet "weeks":


    Sub paste_values2()
        Sheets("Days").Range("j2:j100").Copy
        Sheets("Weeks").Select
        Range("A2").Select
        Do While ActiveCell.Value <> ""
            ActiveCell.Offset(0, 1).Select
        Loop
        Selection.PasteSpecial Paste:=xlPasteValues
    End Sub

  3. #3
    Registered User
    Join Date
    12-12-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Copy and Paste Using a Macro

    Hi NickyC
    Your formula works a treat with one minor problem - on executing the 2nd macro you proposed, the cells on the "Days" sheet in Column "J" remain selected with the marquee.
    Can this be stopped?

  4. #4
    Valued Forum Contributor
    Join Date
    06-09-2010
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    346

    Re: Copy and Paste Using a Macro

    Hi
    adding this before the End Sub should clear it:

    Application.CutCopyMode = False

  5. #5
    Registered User
    Join Date
    12-12-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Copy and Paste Using a Macro

    Hi Nicky
    Yes that worked - you are a champion!!!!

  6. #6
    Valued Forum Contributor
    Join Date
    06-09-2010
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    346

    Re: Copy and Paste Using a Macro

    glad to be of help

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