+ Reply to Thread
Results 1 to 8 of 8

Repeat macro for next row

  1. #1
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    428

    Repeat macro for next row

    Hi Team,

    I've got a macro that will create an email based on the active cell and inputting relative content in to the email from the worksheet

    As it stands, it only works on the activecell. How would I change my coding so that it does the active cell, then goes to the next row (same column) and repeats until the end.

    Here's the code (I've had to strip out some of the HTML coding)

    Please Login or Register  to view this content.
    In the example, I would want an email to be formulated for Fred Bloggs, then another for Joe Soap then another for "Another Person" through to end.

    Any help would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,234

    Re: Repeat macro for next row

    Try:
    Please Login or Register  to view this content.
    Artik

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: Repeat macro for next row

    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,234

    Re: Repeat macro for next row

    sintek, I wonder if With CreateObject("Outlook.Application") shouldn't be before the For Each loop.

    Artik

  5. #5
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    428

    Re: Repeat macro for next row

    Artik and sintek,

    Thank you so much, both suggestions work and achieve what I asked (I'll rep you guys up shortly)

    I have to say there is absolutely NOTHING wrong with sintek's solution, but I'm going to go with Artik's. The reason being that, whether by accident or design, it includes an ability for me to select a certain cell within a row and the macro operates from this point.

    If for example I have an original list of 100 people and send the email to them. Then, at a later date, I add another 50 people (effectively rows 101 - 150), I can select the appropriate cell on row 101, run the macro and it will work from that row onward. This could prove to be invaluable.

    Thank you both again.

    Kindest Regards

    MagicMan

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: Repeat macro for next row

    Quote Originally Posted by Artik View Post
    sintek, I wonder if With CreateObject("Outlook.Application") shouldn't be before the For Each loop.

    Artik
    Nope...Then the same Outlook window is edited...That way a new window is created during each loop...

  7. #7
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,234

    Re: Repeat macro for next row

    MagicMan, you can also use the sintek code slightly modified
    Please Login or Register  to view this content.
    It will be even safer as you do not have to select the cell in column C. You can select in any other column. As important is that the active cell is not in a row below the data range.

    Artik

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,283

    Re: Repeat macro for next row

    @ Artik

    Now I see what you meant...Yes, much better than creating App instance al the time...

+ 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] macro row to repeat at top
    By max_max in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2016, 03:36 PM
  2. [SOLVED] Repeat Macro on Each Row
    By krayon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2015, 01:55 AM
  3. Replies: 4
    Last Post: 03-08-2014, 08:01 AM
  4. [SOLVED] Macro - Repeat macro a specific number of times
    By uvinduds in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-25-2013, 02:42 PM
  5. Repeat macro
    By wrightie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2010, 05:34 AM
  6. [SOLVED] How to repeat a macro
    By Leon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-03-2006, 09:00 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