+ Reply to Thread
Results 1 to 3 of 3

Thread: Maco - Copy, Paste, Find, and Replace

  1. #1
    Registered User
    Join Date
    05-09-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Maco - Copy, Paste, Find, and Replace

    Hi,

    I need help creating a macro that will do the following:

    1) Copy Cell A1
    2) Perform the Find and Replace function, in which the Replace value is the copied value from cell A1.

    Side Note: The value I want to "Find" would be a static value, so I would just build that into my macro, but the "Replace" value changes.

    Here's what I have so far, but it's not working....

    Sub MyMacro()

    Range("A1").Select
    Selection.Copy
    Cells.Replace What:="Static Value", Replacement:=ActiveSheet.Paste, LookAt:= _
    xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    End Sub


    Thanks!
    Last edited by gjohn282; 06-16-2011 at 06:06 PM.

  2. #2
    Valued Forum Contributor p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2003-2010
    Posts
    377

    Re: Maco - Copy, Paste, Find, and Replace

    try this, it should work.

    Sub MyMacro()
    
    Range("A1").Select
    Selection.Copy
    Cells.Replace What:="Static Value", Replacement:=Range("A1"), LookAt:= _
    xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    End Sub
    Pierre

  3. #3
    Registered User
    Join Date
    05-09-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Maco - Copy, Paste, Find, and Replace

    Thank you so much! This worked perfectly!

+ 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