Results 1 to 3 of 3

Selection.Replace replaces in entire workbook despite Range.Select

Threaded View

  1. #1
    Registered User
    Join Date
    12-29-2011
    Location
    USA
    MS-Off Ver
    MS Office Pro Excel Ver 14.0.6023.1000 32 bit
    Posts
    1

    Selection.Replace replaces in entire workbook despite Range.Select

    I am trying to remove the last character in a text string (for a specific range, on a single worksheet) using a macro and it ends up intermittantly removing that character throughout the whole workbook.



    Here is my macro code:

    Range("$G$5:$G$19").Select
    Selection.Replace What:="Z", Replacement:="", LookAt:=xlPart, _
         SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
         ReplaceFormat:=False
    Here is an example of my data:

    12/22/2011 14:23:46Z
    12/22/2011 14:45:12Z
    12/22/2011 16:43:46Z
    ...

    And I want to make it look like:

    12/22/2011 14:23:46
    12/22/2011 14:45:12
    12/22/2011 16:43:46
    ...


    On some occasions, Not everytime, the macro will end up removing the "Z" from the entire workbook, instead of just in the cell range G5:G19.

    I am running the Macro by clicking on a "Button" on the worksheet. I have about 45 worksheets in the workbook and all of them have this button on each worksheet.

    Thanks for the help!
    Last edited by robapodaca; 12-29-2011 at 05:42 PM. Reason: more info

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.6.0 RC 1