+ Reply to Thread
Results 1 to 6 of 6

Copy Paste Macro

  1. #1
    Registered User
    Join Date
    05-28-2012
    Location
    South Africa, Soweto
    MS-Off Ver
    2007
    Posts
    16

    Copy Paste Macro

    Please assist, i have a macro that works perfectly fine with one workbook (ADH Feb'13 new WorkfileDownload.xlsm) but refuses to ran with the other ones (ILA Feb'13 WorkfileDownload.xlsm, CBH Feb '13 WorkfileDownload.xlsm, etc).

    The problem i figured out is that may be i Dim only one file name, so how do i strFileFrom to include every open/active workbook.



    Sub Macro1()
    Dim strFileFrom As String
    Dim strFileTo As String

    strFileFrom = "ADH Feb'13 new WorkfileDownload.xlsm"
    strFileTo = "Template.xlsx"

    Windows(strFileFrom).Activate
    Sheets("Top 20 Line Entries").Select
    Range("B3:B22").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows(strFileTo).Activate
    Sheets("Top 20 Line Entries").Select
    Range("B14").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End Sub

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy Paste Macro

    Ponjo,
    Please use code tags with your code.
    You can use active workbook, so that as long as you are on that book, it should work.
    If you are opening a workbook which is not open, you need to change the syntax and use open file

  3. #3
    Registered User
    Join Date
    05-28-2012
    Location
    South Africa, Soweto
    MS-Off Ver
    2007
    Posts
    16

    Re: Copy Paste Macro

    HI AB33 i did change to active workbook but now am getting some of my code below highlighted in yellow (example: Sheets("Top 20 FM").Select)

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy Paste Macro

    This is a recorded macro. I have amended the first few lines of the code and hopefully you should be able to do the rest

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-28-2012
    Location
    South Africa, Soweto
    MS-Off Ver
    2007
    Posts
    16

    Re: Copy Paste Macro

    thanx but i figured the problem its working fine with any open workbook

    thanx again God Bless you

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy Paste Macro

    Ponjo,
    You are welcome!

    Could you please now close (Mark) this thread as solved? Go in to the top right-hand side of this page, choose "Thread Tools" from the menu, then select "solved" from the drop down menu.

+ 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