+ Reply to Thread
Results 1 to 4 of 4

Find, then copy and paste macro not working

  1. #1
    Forum Contributor
    Join Date
    12-11-2010
    Location
    Indiana, USA
    MS-Off Ver
    Excel 2007
    Posts
    118

    Find, then copy and paste macro not working

    I have used this macro so many times in the past, and it is used throughout this workbook to collect all kinds of information.
    But it seems to choke on this little simple task!
    I am trying to overwrite the oldest of two entries in two rows with a fresh row of data...
    Am I missing something?
    I have posted a section of my project, with the cells in the same address as the original to match the macro
    The macro is in a textbox under the cells in question
    Thank you for taking a look.
    Attached Files Attached Files

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

    Re: Find, then copy and paste macro not working

    Hello ufopilot,

    You have made a common mistake when using the Find method for a Range. Because the Find method used for a Range object is the same structure as the Windows Find/Replace dialog, many of the values are retained after they have been used. This is one instance where VBA does not clear all the variables after the Sub or Function ends. Get into the habit of setting these variables when you use the Find method and you will eliminate a lot of problems.

    From the VBA Help Files
    The settings for LookIn, LookAt, SearchOrder, and MatchByte are saved each time you use this method. If you don’t specify values for these arguments the next time you call the method, the saved values are used. Setting these arguments changes the settings in the Find dialog box, and changing the settings in the Find dialog box changes the saved values that are used if you omit the arguments. To avoid problems, set these arguments explicitly each time you use this method.

    Corrected Code is in Blue
    Please Login or Register  to view this content.
    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
    Forum Contributor
    Join Date
    12-11-2010
    Location
    Indiana, USA
    MS-Off Ver
    Excel 2007
    Posts
    118

    Re: Find, then copy and paste macro not working

    Hi Leith,
    Thank you for your reply. I read the information you provided, but have been unsuccessful in solving my problem.
    Then,I have tried the easy way - copying the whole code you replied with, and pasting it over the original.
    The code hung up at the same area in question. I changed the "Find" to the actual value of the formula from "M85" to "x", but still the same result...the code hangs up at the same place.

  4. #4
    Forum Contributor
    Join Date
    12-11-2010
    Location
    Indiana, USA
    MS-Off Ver
    Excel 2007
    Posts
    118

    Re: Find, then copy and paste macro not working

    Keith,
    I noticed that my formula was not working as expected. This may have had something to do with the military time format I am using.
    Instead of a formula in M85, I changed the formula K88:K89, I to: IF(AY88=MIN($AY$88:$AY$89),"x",""), which gives me the the value("x" in M85 directly.
    I placed the original macro back in, and all is well. But you gave me more food for thought, and this can only be a benefit to me. Thank you for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to copy, then paste row in multiple sheets not working
    By dystopianprotagonist in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2013, 09:37 PM
  2. [SOLVED] Macro to Find, copy, paste, find, copy, paste, find, copy, paste, u get the picture....
    By westsoldman in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-12-2012, 01:12 AM
  3. Code: Find, Copy, Paste not working
    By ufopilot3 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-26-2012, 03:40 PM
  4. copy paste macro not working
    By nicko54 in forum Excel General
    Replies: 1
    Last Post: 01-05-2011, 05:25 PM
  5. Copy/Paste Merged Cells via Macro is not working
    By Peter Bassett in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2005, 04:06 PM

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