+ Reply to Thread
Results 1 to 4 of 4

for each loop dosn't work

  1. #1
    Registered User
    Join Date
    03-04-2019
    Location
    Quebec
    MS-Off Ver
    2016
    Posts
    4

    for each loop dosn't work

    Hi guys

    I have a private sub which calls my macro when any cell within a row (A1 tp end Right) changes to "Delivered" . then Macro2 copies the entire related column and paste the value in another sheet. for some reason Macro2 does not work. It doesn't even give me an error so I can work on. I will appreciate if you can guide me on this

    Please Login or Register  to view this content.
    ------------

    Please Login or Register  to view this content.

    Thank you for any help in advance
    Last edited by rhamid6; 03-13-2019 at 09:45 AM.

  2. #2
    Forum Contributor
    Join Date
    05-12-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    266

    Re: for each loop dosn't work

    why two different subs to do the job? try it please.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-04-2019
    Location
    Quebec
    MS-Off Ver
    2016
    Posts
    4

    Re: for each loop dosn't work

    Thank you so much for your answer. That worked very well. Instead of copying and pasting entire related column, is it possible to copy and paste only a few cells of that column? I want to say If the word "Delivered" was found copy only some specific cells of that column and paste it as special. (cells rows (3 to 10), related columns) and cells (rows(16 to 20), related column).

    Please Login or Register  to view this content.
    for the first part I tried that but it gives me an error that the method is not supported. Thank you for you help
    Last edited by rhamid6; 03-19-2019 at 01:58 PM.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: for each loop dosn't work

    This question crops up time and time again and if we had a FAQ area that dealt with Excel stuff rather than forum stff it would be my numero uno.

    Whenever you find yourself writing looping code, stop, take a breath and think if there isn't a better way. Using loops to do this sort of stuff, particularly when you are processing large ranges is inherently slow because of the need to jump back and forth between VBA and the Excel app., which carries a big time overhead.

    The fastest and most elegant and efficient way I know to do this is by filtering.

    Identify the column that contains the values you want to use for selecting rows - presumably in your case the column with the "7 Delivered" text.
    AutoFilter your range to display these rows.
    Then use
    Range("your_big_range").SpecialCells(xlCellTypeVisible).Copy

    and then paste them as values to your destination, finally removing the Auofilter.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ 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] Add a blank row after the loop done the work and run the loop from the next row
    By IonutC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2016, 04:31 AM
  2. [SOLVED] Dosn't work if I use range of address (AVERAGE, IF, WEEKDAY)
    By hbartolin in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 08-26-2016, 07:27 AM
  3. [SOLVED] Cannot get loop within a loop to work
    By forrestgump1980 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-04-2015, 10:02 AM
  4. [SOLVED] dosn`t save properly
    By Eddy S in forum Excel General
    Replies: 7
    Last Post: 04-22-2013, 07:45 PM
  5. Macro dosn't work next day
    By Dixxon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2008, 05:15 AM
  6. VBA Help, cant figure out why it dosn't work.
    By Michael A in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2006, 11:30 AM
  7. Why dosn't my pointer change to a double-headed arrow to drag?
    By Kab in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-05-2005, 11:05 AM

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