+ Reply to Thread
Results 1 to 16 of 16

Special cut, paste and replace

  1. #1
    Forum Contributor
    Join Date
    04-04-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    204

    Special cut, paste and replace

    Hi Guys,

    I have worksheet with data distributed over 4 columns, and over 25000 rows.

    Data are grouped and each group is separated with one empty row from the other.

    ColC has the core data, where certain words are formatted in red colour in each row.

    What is needed is that each red string regardless of its length in each row is to be cut, pasted in ColE in the same row, and replaced with ten dots in ColC.

    Attached is a made up example to illustrate the case. Sheet1 with data before replacing red strings, and Sheet2 after replacement with ColE added strings.

    Highly appreciating any valuable assistance.

    Many thanks.
    T.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    03-10-2013
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Special cut, paste and replace

    Dear terryhenderson

    Try this
    If I helped you press a button * AddRep

    Hi Pan314


    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-04-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    204

    Re: Special cut, paste and replace

    Hi Pan314,

    Thank you very much for your time and effort spent on helping with my problem.
    Just wondering if you have run your code on my sample file for testing. As I ran the code, I found:
    1. it doesn't default to ColC to work on.
    2. it works for one row at a time and does not loop to the next, ie I have to run it manually for every single row.
    Is there any chance to have this fixed, please?

    With my best regards,
    T.

  4. #4
    Forum Contributor
    Join Date
    03-10-2013
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Special cut, paste and replace

    Dear terryhenderson

    I wrote earlier that the code should be included in a cycle. This is now done. I hope that you can use. Try this


    If I helped you press a button * AddRep

    Hi Pan314


    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-04-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    204

    Re: Special cut, paste and replace

    Dear Pan314,

    Once again, thank you very much for your contribution to solve my problem.
    The code is working, but extremely slow. It took 3 minutes to finish 42 rows. How long do you think it would take to finish over 25000 rows?
    I hope there'll be some way to enhance the code performance, so this task is done quickly and accurately.

    With my best regards,

    T.

  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: Special cut, paste and replace

    Another:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    04-04-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    204

    Re: Special cut, paste and replace

    Hi John H. Davis,

    Such a rocket code. It does the job, but instead of replacing red text with 10 dots, it counts the red letters and replaces them accordingly. Is it possible to fix the replacing dots to ten dots only?

    Very much appreciated.

    T.

  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: Special cut, paste and replace

    Try:

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    04-04-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    204

    Re: Special cut, paste and replace

    Thank you very much John for such marvelous code, it ran very smoothly and did the job as exactly desired.
    My deep thanking and gratitude.
    All the best.
    T.

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

    Re: Special cut, paste and replace

    You're welcome. Glad to help out and thanks for the feedback.

  11. #11
    Forum Contributor
    Join Date
    04-04-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    204

    Re: Special cut, paste and replace

    Hi JOHN H. DAVIS,

    As we are running your code on different texts and even different languages, such as Arabic and Korean, we found:
    1. for English short strings, absolutely no problem and performance is optimum.
    2. for English, Arabic and Korean strings longer than 255 chars the code halts for a debug
    3. for Arabic and Korean short strings, performance speed dramatically goes down for calculation.

    Any precious suggestions?

    With my best regards.
    T.

  12. #12
    Forum Contributor
    Join Date
    04-04-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    204

    Re: Special cut, paste and replace

    Hi Guys,

    As I proceeded with my question regarding this very topic of "Special cut, paste and replace" I received two masterpieces of code by both respected experts Pan314 and John H. Davis. Both scripts worked excellently on our English files.

    The script performance speed was far much faster for that of John H. Davis', which made us prefer using it on large files of data, without any devaluation of Pan314 script.

    On the course of work, I encountered a file in Arabic that needed to be processed as exactly as that in English. When I ran John's code, it halted for a debug to define character class, whilst running Pan314's script it actually did the job perfectly, but after a significant period of time.

    I am putting both scripts in an attached example to the general community of the forum so that another look into both scripts may "unlock the genie". The attached file has two sheets, where Sheet1 has the Arabic text cited from the Holy Book, and the second as a backup for that text just in case.

    That's it.

    My thanking and greetings in advance.

    T.

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

    Re: Special cut, paste and replace

    Hi Terry:

    See if this modification of Pan314's code helps any? I not familiar with Arabic, so I can't be of much help trying to determine why mine is erroring out.

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    04-04-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    204

    Re: Special cut, paste and replace

    Hi John,

    Thank you very much for such quick response. As I ran the script, it halted with a run-time error 1004 "unable to set the text property of the Character class", and it stopped at:
    Please Login or Register  to view this content.
    Any suggestions?

    My best regards,
    T.

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

    Re: Special cut, paste and replace

    I modified Pan314's code because you said it didn't error in Post#12. Looks like the same error as you cited in Post #12 for my. When I tested it, I didn't receive an error and it ran through and did something. However, since I don't know Arabic, I couldn't tell if it did what it was supposed too do. Try this one then:

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    04-04-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    204

    Re: Special cut, paste and replace

    Marvelous, the code ran smoothly without any halts. It is much faster than its first version, but still slower than expected and I think it returns to the nature of the structure of Arabic text which, I think, there's no much for us to do about it.

    I truly believe that both of you John and Pan314 have done more than expected with this problem, which is solved from this point on.

    Thank you very much for every minute you spent and effort you exerted in solving this problem.

    My best personal regards.

    T.

+ 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. [SOLVED] find replace and paste special values
    By Blake 7 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-10-2014, 05:53 AM
  2. Macro to copy and replace with paste special
    By Mysore in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-18-2013, 02:03 AM
  3. Replies: 1
    Last Post: 12-05-2012, 11:37 AM
  4. [SOLVED] how can I paste text using paste special, without clicking paste button?
    By Exxcel Noob in forum Excel General
    Replies: 6
    Last Post: 05-14-2012, 08:21 PM
  5. [SOLVED] Excel VBA Paste Special - replace contents of destination cells
    By Sam via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2012, 12:44 PM
  6. Paste Special, replace contents of destination
    By Cookstein2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-08-2009, 04:35 AM
  7. Paste Special Values/Replace - Problems
    By Jokacave in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-21-2008, 09:57 AM

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