Results 1 to 18 of 18

error 1004 replace method of range class failed

Threaded View

  1. #1
    Registered User
    Join Date
    06-01-2014
    Posts
    8

    error 1004 replace method of range class failed

    Hi all,
    First time poster here, very much a VBA novice- hoping you can help me out!
    I have a sheet of 64227 lines. I've used a substitute formula to get down to a list of categories in column J.
    Because of the substitute formula, each cell contains duplicate values: eg category one, category 1, category 1, category 2.
    I need these cells to just display "category one, category two".
    I've been manually finding and replacing but the scale of the sheet is making this unmanageable.

    So I've created a find and replace macro using this formula:

    Sub ReplaceText()
    
    Dim myList, myRange
    Set myList = Sheets("Sheet1").Range("A2:B332")
    Set myRange = Sheets("Client").Range("J2:J64227")
    For Each cel In myList.Columns(1).Cells
    myRange.Replace What:=cel.Value, Replacement:=cel.Offset(0, 1).Value, LookAt:=xlWhole
    Next cel
    
    End Sub
    But when I click "Run Macro" it converts some values, but not others.
    Debugger points to this line : myRange.Replace What:=cel.Value, Replacement:=cel.Offset(0, 1).Value, LookAt:=xlWhole

    But I can't work out what's causing the problem there.
    I've googled for hours, can anyone shed light on this for me?
    Thanks!
    Last edited by alansidman; 06-01-2014 at 05:08 PM. Reason: code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. error 1004 AutoFill method of Range class failed
    By aritzel12 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-17-2013, 01:59 PM
  2. [SOLVED] error 1004 select method of range class failed
    By Lee_wwfc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-23-2013, 12:34 PM
  3. Run-time error '1004' - Select method of Range class failed
    By g10drac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-08-2011, 08:03 PM
  4. Runtime error 1004: Insert method of Range class failed......not sure why
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-21-2011, 02:15 PM
  5. sort method of range class failed error 1004
    By droberts77uk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-23-2009, 11:09 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