+ Reply to Thread
Results 1 to 10 of 10

Can't change code from Columns to Lines

  1. #1
    Registered User
    Join Date
    12-17-2013
    Location
    Lisbon
    MS-Off Ver
    Excel 2007
    Posts
    24

    Can't change code from Columns to Lines

    Hello everyone,

    I know, title is weird, but this is what happens.
    I have a piece of code, that send emails from excel with an attachment.

    At the moment, I have to place the data in Excel this way, so each Column is a single email.
    A1 is To:
    A2 is Subject:
    A3 is Body:
    A4 is File:

    And I want to place data like this, so each line is a single email.
    A1 is To B1 is Subject C1 is Body D1 is File

    Can you guys please help me ?

    Here's the Code:

    Please Login or Register  to view this content.
    Here is an example in Excel that would explain properly what I need.

    Example.xlsx

    Tried many things already, but can't get it to work.
    I feel it's in front of me on the Offset values, but I don't understand it and can't get it to work like I want to.

    Also, if I am not mistaken, that code sends a maximum of 3 emails ( Set rngEntries = ActiveSheet.Range("B1:D1" ). Is there a way to send all emails without a range ? For example, stop if a cell in the " To: " Column is empty ?

    Many thanks guys !

  2. #2
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Can't change code from Columns to Lines

    This will do what you requested;
    Please Login or Register  to view this content.
    If I helped in any way, please click the star

  3. #3
    Registered User
    Join Date
    12-17-2013
    Location
    Lisbon
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Can't change code from Columns to Lines

    Hello.
    It gives an error in
    " .Attachments.Add rngEntry.Offset(, 3).Value "

    Says: "Path does not exist."

    Yeah, I placed the path to the files correctly, more then once actually.

  4. #4
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Can't change code from Columns to Lines

    I tested the code with my files and it worked perfectly.
    Are you sure your FULL path was placed in the cell?

    Here's the exact text I used in Column D and I had no problem.
    C:\Users\Jim\Pictures\01\0001.png

    The code will also error out if no file path is placed in column D (ie. blank cell)
    So every cell in column D must contain a valid file path and file.
    Last edited by Jim885; 11-03-2014 at 11:42 AM.

  5. #5
    Registered User
    Join Date
    12-17-2013
    Location
    Lisbon
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Can't change code from Columns to Lines

    I'm testing with 3 files, and it's stuck there, gives that error and does nothing more.
    And yeah, all others cells bellow D4 are blank.

    I don't understand, the Path to the files is correct :|

  6. #6
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Can't change code from Columns to Lines

    The code also assumes you are not using headers. Thus it starts at A1 like you requested ---
    "And I want to place data like this, so each line is a single email.
    A1 is To B1 is Subject C1 is Body D1 is File"

    If you are using headers, then change this line of code;
    Please Login or Register  to view this content.
    to this;
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-17-2013
    Location
    Lisbon
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Can't change code from Columns to Lines

    Ok. Was the headers :|
    THANK YOU !
    Works Amazingly and will spare me so much time !
    Will have to check the code you changed so I can understand it.
    Can't thank you enough !

  8. #8
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Can't change code from Columns to Lines

    Quote Originally Posted by Darker0ne View Post
    I'm testing with 3 files, and it's stuck there, gives that error and does nothing more.
    And yeah, all others cells bellow D4 are blank.

    I don't understand, the Path to the files is correct :|
    If you are always sending three files, then add these lines directly underneath the first line that looks like this ... .Attachments.Add
    Please Login or Register  to view this content.
    And make sure you have the additional file paths in columns E and F

  9. #9
    Registered User
    Join Date
    12-17-2013
    Location
    Lisbon
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Can't change code from Columns to Lines

    I apologize for my english.
    I was testing with 3 entries, but i had headers. Now works perfectly.
    I only send one file, but is a personalized file, file x is to person A, and file y is to person b.
    But cool, in case i need to send more then one file
    Thanks a lot !

  10. #10
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Can't change code from Columns to Lines

    Glad we got it solved.
    Please select Thread Tools from the menu link at the top of this page and mark this thread as SOLVED.
    And if you don't mind, please check the star on the llower left of this post.
    Thanks!
    Last edited by Jim885; 11-03-2014 at 12:16 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] Code lines color and hide columns
    By Tyso in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-10-2013, 03:49 AM
  2. macro to autofilter and copy first 15 lines visible lines in columns D:E
    By Juraj123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2013, 03:40 AM
  3. [SOLVED] varying number of columns, multiple similar lines of code (needs condensing)
    By intothewild in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-25-2012, 12:32 PM
  4. [SOLVED] Copy content of several columns into a single cell and change format on separate lines
    By Biffilicious in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2012, 05:05 AM
  5. Text to columns VBA code to change delimiter if the cell value is in array
    By dopple in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-26-2008, 09:25 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