+ Reply to Thread
Results 1 to 8 of 8

Macro to Find and Replace

  1. #1
    Registered User
    Join Date
    02-05-2015
    Location
    United States
    MS-Off Ver
    2007
    Posts
    13

    Macro to Find and Replace

    I am trying to make a macro find and replace one week with another. I have the two cells to reference the two weeks and I created a macro but it doesn't work. It just highlights the cells I need replaced and that is all. Not sure what I am doing wrong.

    Sub FindReplace()
    '
    ' FindReplace Macro
    '

    '
    WeekNum1 = Cells(5, 15) 'previous week location
    WeekNum = Cells(4, 15) 'location of week

    Columns("A:L").Select
    Cells.Replace What:="Week " & WeekNum1 & " ", Replacement:="Week " & WeekNum & " " , LookAt:=xlPart, SearchOrder _
    :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

    End Sub

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Macro to Find and Replace

    Try this instead:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-05-2015
    Location
    United States
    MS-Off Ver
    2007
    Posts
    13

    Re: Macro to Find and Replace

    I tried it but it is just sitting there. It's like it doesn't know where to pull from. When I run it with Week 6 and Week 7 it works perfectly, but with the Week &WeekNum&, it doesn't work. But, I need the macro to look at what the current week is because it will be constantly changing.

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Macro to Find and Replace

    Post your workbook or a sample workbook demonstrating what you want, please.

  5. #5
    Registered User
    Join Date
    02-05-2015
    Location
    United States
    MS-Off Ver
    2007
    Posts
    13

    Re: Macro to Find and Replace

    I am trying to get the Week #'s in the formulas to update with find and replace each new week, which can be changed in cell O4.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to Find and Replace

    Maybe:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-05-2015
    Location
    United States
    MS-Off Ver
    2007
    Posts
    13

    Re: Macro to Find and Replace

    Thank you. That worked perfectly!!!

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to Find and Replace

    You're welcome. Glad to help out and thanks for the feedback. Please mark this thread as solved.

+ 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. Replies: 3
    Last Post: 11-25-2014, 06:08 AM
  2. Replies: 2
    Last Post: 06-12-2013, 03:48 PM
  3. Find/Replace Macro Using Replace Table
    By LampCommandr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-24-2011, 11:00 AM
  4. Optimizing Excel macro to find/replace with the list of data contained in the macro
    By Iceyburnz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2008, 08:41 PM
  5. [SOLVED] Using Find and Replace to replace " in a macro
    By snail30152 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2006, 06:58 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