+ Reply to Thread
Results 1 to 8 of 8

Copy/Paste Macro

  1. #1
    Registered User
    Join Date
    04-12-2010
    Location
    MD
    MS-Off Ver
    Excel 2003
    Posts
    9

    Copy/Paste Macro

    I am having an issue with a macro I created. In a brand new workbook, the following works:

    Please Login or Register  to view this content.
    The problem I encounter is when trying to apply this to an existing workbook. I get a Run-Time Error '13': Type Mismatch.

    It stops at the line ActCellVariable = Range(RngActCell).Value.

    I have tried to use the If Error Resume Next and it keeps the dialog box from popping up but does not copy the value into the new cell.

    Can someone please help?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,929

    Re: Copy/Paste Macro

    So, presumably, the cell being copied has somthing in it that isn't a string.

    Which cell is being copied and what is in it?

    I'm guessing it is a formula with an error condition lik #DIV/0! or #N/A

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    04-12-2010
    Location
    MD
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Copy/Paste Macro

    The cell's themselves that I want to copy are formatted as follows:

    AA1234
    or
    123456

    The thing that might be causing the error is the cell directly above them has a VLOOKUP that references the cell I'm trying to copy.

    I would post a copy of the workbook but I can't because my work won't let me.

    * Edit *

    I just checked and there are other areas of the workbook that the macro works so it is the VLOOKUP in the cell above that is causing the error.
    Last edited by MFO_Jester; 11-03-2011 at 04:16 PM. Reason: Additional Information

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,929

    Re: Copy/Paste Macro

    Can you put together a small sample withe the cell that you want to copy and the cell that references it? If you can simulate the problem, can you post the sample workbook? From work or home.

    I can reproduce the problem if the cell being copied has a #DIV/0! in it. Can't see why another cell would hiccup.

    Happy to look at it for you but, at the moment, there's not much I can suggest.

    Regards

  5. #5
    Registered User
    Join Date
    04-12-2010
    Location
    MD
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Copy/Paste Macro

    Alright... Attached is a severely dumbed down version of the workbook.

    I essentially want to use the macro to copy/paste the cell with "12345" to the cell directly to the right.

    Let me know what you can figure out.

    Thanks,
    Attached Files Attached Files

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,929

    Re: Copy/Paste Macro

    OK. The value 12345 is in a merged pair of cells, A2:B2. When you run the macro and get the address of the selection, it picks up $A2:$B2.

    So, Excel is unhappy about trying to copy two cells' values into one string variable.

    Try:

    Please Login or Register  to view this content.
    Or get shut of the merged cells ... which would be my recommendation.


    Regards

  7. #7
    Registered User
    Join Date
    04-12-2010
    Location
    MD
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Copy/Paste Macro

    Thanks that worked.

    I appreciate all of your help.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,929

    Re: Copy/Paste Macro

    You're welcome.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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