+ Reply to Thread
Results 1 to 2 of 2

find and replace

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-26-2010
    Location
    usa
    MS-Off Ver
    Office 365
    Posts
    1,224

    find and replace

    Hello

    I have the following macro which copies data from selected range and paste the formulas into the other worksheets...however, it's for some reason, not changing or find/replacing the worksheet name :S

    Sub CopyToAll()
    Dim ws          As Worksheet, _
        wslist()    As Variant, _
        testval     As Variant
     
    wslist = Array("Vancouver-Kelowna", "Canada East", "Canada West", "US Northeast", "US Central", "US Southeast", "US West", "US Total", "Canada Total")
    For Each ws In ActiveWorkbook.Worksheets
        testval = Application.Match(ws.Name, wslist, 0)
        If IsError(testval) And ws.Visible Then
            Sheets("Vancouver-Kelowna").Range("B5:X5").Copy Destination:=ws.Range("B5")
            Sheets("Vancouver-Kelowna").Range("B62:X62").Copy Destination:=ws.Range("B62")
            ws.Cells.Replace What:="\\Shrdfs1\teams\Sales Analyst\SWAT\Archieve 2011\P1W4\[Vancouver-Kelowna.xls]Ghost Summary'!$C$8", Replacement:="\\Shrdfs1\teams\Sales Analyst\SWAT\Archieve 2011\P1W4\[" & ws.Name & ".xls]Ghost Summary'!$C$8", LookAt:=xlPart, _
                SearchOrder:=xlByRows, MatchCase:=True
        End If
    Next ws
    End Sub
    any ideas..pls help, thx you.

  2. #2
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: find and replace

    I'm not a VBA expert but aren't you asking the code to do that copy/paste only when there is NO match to the sheet name AND the sheet is visible????

+ 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