+ Reply to Thread
Results 1 to 3 of 3

Selection.Replace replaces in entire workbook despite Range.Select

  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:

    Please Login or Register  to view this content.
    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

  2. #2
    Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    280

    Re: Selection.Replace replaces in entire workbook despite Range.Select

    Hi

    If you perform a dummy find first, then run your correct Find/Replace, it should reset the scope to just the current worksheet (which is what you want) if Find/Replace dialog has previously been amended to scope:workbook:

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Selection.Replace replaces in entire workbook despite Range.Select

    I beleive you need to kill excel to so selection find / treplaces so add a code before the VBA find / replace sections ie a lot of code really I have fully written for you so hope easier to read and understand
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

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