+ Reply to Thread
Results 1 to 5 of 5

Insert range value in email until empty cell

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

    Insert range value in email until empty cell

    Hi folks,

    I have a workbook that, through a loop produces, bespoke emails to individuals as required.

    What I'd like to do is rather than (as it currently stands) I have to individually list every cell in the range A;A of the "Message Body" tab, it automatically inserts those values in the email until it reaches an empty cell.

    In the example sheet, it would automatically insert cells A1, A2 and A3 of the "Message Body" tab in to the email it produces.

    I may be wrong, but I'm guessing it's a loop within the existing loop, I'm just not sure how it all gets put together.

    Thanks Team

    MM
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    02-06-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    373

    Re: Insert range value in email until empty cell

    Hey, just going to speak conceptually here, let me know if you need more specific detail.

    What I've done in the past is created a range variable, e.g. dim rng as range, set the range to a starting point, e.g. set rng = ThisWorkbook.Sheets("mySheet").Range("A1"), created a while loop that says while rng.value <> "" do this. At the bottom of the while loop set rng = rng.Offset(1, 0) (set down 1 row).

    You can reference the value in the range directly as rng.Value, or an offset by rng.Offset(row, col).value

    I think that's what you're trying to accomplish here.

    You're right in thinking that a loop within a loop is the idea.
    Last edited by 1aaaaaaaaaaaaaaa; 07-19-2023 at 03:44 PM.

  3. #3
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    427
    Hi Poizhan,

    That looks like it makes sense. If you can give me a more spcific explanation I would be very grateful.

    MM

  4. #4
    Valued Forum Contributor
    Join Date
    02-06-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    373

    Re: Insert range value in email until empty cell

    Something like

    Please Login or Register  to view this content.

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

    Re: Insert range value in email until empty cell

    EDIT: NO NEED - I've cracked it :-) Rep added

    Hi Poizhan,

    I'm possibly being incredibly dense, but can you let me know where it would go in my existing code (on the example spreadsheet) please.

    I can see the logic of that bit of code, but am really a bit clueless as to where it should go to make it work.

    Thank you

    MM
    Last edited by MagicMan; 07-19-2023 at 04:57 PM.

+ 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] Using macro to find first empty cell in column. If range is empty returns error.
    By A440 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-23-2019, 11:03 AM
  2. [SOLVED] insert values into empty cells in a range only
    By Ramzes in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-26-2018, 12:24 PM
  3. [SOLVED] How to create a dynamic range if the last cell is empty and the columns have empty cells
    By peter_swe in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2016, 11:18 PM
  4. Replies: 0
    Last Post: 08-03-2016, 07:01 PM
  5. [SOLVED] Insert a range from 2 or more different worksheets into the same email
    By KAPearson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-22-2014, 07:05 PM
  6. Insert formula only in non-empty cells in a range
    By ciprian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2013, 08:01 AM
  7. [SOLVED] Find empty cells in a range and insert formula in adjacent cell
    By macronovice1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-25-2012, 03:06 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