+ Reply to Thread
Results 1 to 3 of 3

loop macro - copy, paste, run macro

  1. #1
    Registered User
    Join Date
    06-01-2015
    Location
    Prague
    MS-Off Ver
    2010
    Posts
    1

    loop macro - copy, paste, run macro

    Hi, I am relatively new to VBA and therefore I would like to ask you for a help with VBA macro.

    a) Current state

    Worksheet "Customers" contains all our customers IDs in range B4:B72
    Workheet "Send to customer" contains formulas which calculate current stock for one customer(When you insert his ID in cell B6)

    VBA macro "Send email" saves Worksheet "Send to customers" as PDF and send it via e-mail to customer with ID in Cell B6

    The problem is, that every time you want to send email to a customer you have to manually insert his ID in cell B6 (data validation button) and run a macro "Send email", but once per month we send the current level of stock to all our customers, hence we need a loop macro to get rid of manually inserting IDs over and over again.


    b) Desired state:

    Loop Macro "send e-mail to all":

    Logic:

    1) Select "ID of customer 1" (cell B4) from worksheet "Customers", insert that ID in cell B6 in worksheet "Send to customer", wait 10s to calculate formulas, run macro "Send email"
    2) Select "ID of customer 2" (cell B5) from worksheet "Customers", insert that ID in cell B6 in worksheet "Send to customer", wait 10s to calculate formulas, run macro "Send email"
    ...

    69) Select "ID of customer 69" (cell B72) from worksheet "Customers", insert that ID in cell B6 in worksheet "Send to customer", wait 10s to calculate formulas, run macro "Send email"


    Thanks in advance for your help.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: loop macro - copy, paste, run macro

    Assuming:

    1) First customer ID in B4
    2) Last customer ID currently B72 but nothing is below that and more customers MAY get added in the future and we need to dynamically spot the last customer ID in that column
    3) No blank cells are in the middle of the data in column B
    4) This macro will be installed IN this workbook

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    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: loop macro - copy, paste, run macro

    If your version of outlook works like mine then Outlook introduces a 5 second delay between sending emails via an automatic process. You may find that introducing another 10 second delay is not necessary.
    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] how to copy paste through loop this macro
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-06-2014, 06:19 AM
  2. Copy Paste Macro Loop
    By RiteshChaturvedi in forum Excel General
    Replies: 6
    Last Post: 12-20-2013, 01:20 PM
  3. Macro to Copy and Paste and loop
    By bwhite1986 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-16-2012, 10:19 AM
  4. [SOLVED] Copy/Paste Loop Macro
    By danderson2692 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-15-2012, 08:01 AM
  5. Copy and Paste Loop-a macro
    By japorms in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-19-2006, 04:07 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