+ Reply to Thread
Results 1 to 4 of 4

For Each Loop takes forever . Need suggestions please

  1. #1
    Registered User
    Join Date
    07-19-2019
    Location
    USA
    MS-Off Ver
    2013,2016
    Posts
    1

    For Each Loop takes forever . Need suggestions please

    Guys , Need Advice

    Sample data
    Column A
    EXTR0993809 - Detailed description

    I need to split column A and replace (as below)
    Column A
    Detailed description

    Column B
    EXTR0993809

    Note: Sometimes , Column A may have only detailed description .

    Below code does that ,however it takes really long time. Please help to find better solution

    Set RNG = wstarget.ListObjects("WorksheetName").ListColumns(COLUMNA).DataBodyRange

    For Each Cell In RNG.Cells
    If (Left(Split(Cell.Value, " ")(0), 4)) = "EXTR" Then
    Cell.Offset(0, off) = Trim(Split(Cell.Value, "-")(0))
    str = Split(Cell.Value, "-", 2)(1)
    Cell.Value = RemoveLeadingChr(str)
    Else: End If
    Next Cell

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,508

    Re: For Each Loop takes forever . Need suggestions please

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: For Each Loop takes forever . Need suggestions please

    You can speed things up by writing the table content to memory and then process it.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,452

    Re: For Each Loop takes forever . Need suggestions please

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

+ 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] InStr macro takes forever.
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-06-2017, 10:40 AM
  2. Macro Takes forever To Execute
    By daveyc18 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-16-2014, 11:14 AM
  3. VBA that hides rows with 0 takes FOREVER to run
    By Sky188 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-28-2013, 04:04 PM
  4. Copying column w/ VBA takes forever
    By patatvs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2010, 01:42 PM
  5. hiding a few rows with a macro takes forever
    By Conor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-09-2007, 06:34 PM
  6. Workbook takes forever to open
    By drgreig in forum Excel General
    Replies: 4
    Last Post: 08-11-2005, 03:05 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