+ Reply to Thread
Results 1 to 12 of 12

Create excel files based on requirement and email automatically?

  1. #1
    Forum Contributor
    Join Date
    01-01-2022
    Location
    India
    MS-Off Ver
    Home 2021
    Posts
    896

    Create excel files based on requirement and email automatically?

    Hi all,

    Hope all are well.

    I am trying macro for below steps. but i get below error. Not sure where its going wrong.

    Below are the requirements.

    1. Copy all data in sheet "Source_Data" from Source file in a new excel workbook with sheet renamed as "Source Data".

    2. Select all the data present in sheet "Source Data" and create a pivot table in a new sheet with pivot table name as "My Pivot". Rename this sheet as Pivot Table.

    3. In pivot table My Pivot", keep ALERT_DATE (UTC) in field rows grouped by days, UNIQUE_ALERT_ID in field values, COUNTRY/REGION in rows field.

    4. Save this new workbook as "Current Log - " followed by current date in YYYYMMDD format in user's downloads folder.

    5. Attach this workbook in a new outlook mail with below content in the body of mail

    "Dear all,

    Please find attached.

    Additionally, refer (Logs 2024) "

    6. To field in outlook mail should contain below address

    [email protected]

    7. Cc field in outlook mail should contain below addresses

    [email protected]
    [email protected]

    8. Subject of outlook mail shall be "Current Log - " followed by current date in YYYYMMDD format.

    Note: Macro will be run from Source file from button in sheet Run

    Source File is the one from which macro will run.

    "Current Log - 20241015" is the result file.

    Text in red is actually hyperlink but not sure how to keep it as hyperlink in macro.

    Can someone please check and help why macro in source file is not working. Thanks in advance.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by rizwanulhasan; 10-15-2024 at 07:34 AM.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,601

    Re: Create excel files based on requirement and email automatically?

    Try

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-01-2022
    Location
    India
    MS-Off Ver
    Home 2021
    Posts
    896

    Re: Create excel files based on requirement and email automatically?

    @ByteMarks

    Thanks for you response.

    Tried but in error
    Attached Images Attached Images
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,601

    Re: Create excel files based on requirement and email automatically?

    That's disappointing. It's working for me.

  5. #5
    Forum Contributor
    Join Date
    01-01-2022
    Location
    India
    MS-Off Ver
    Home 2021
    Posts
    896

    Re: Create excel files based on requirement and email automatically?

    Still same for me. The new file is being created but the macro stops with aforementioned error code at the point as in below image
    Attached Images Attached Images
    Last edited by rizwanulhasan; 10-16-2024 at 03:14 AM.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,812

    Re: Create excel files based on requirement and email automatically?

    Does this work (selecting second cell, not first):

    Please Login or Register  to view this content.
    Never use Merged Cells in Excel

  7. #7
    Forum Contributor
    Join Date
    01-01-2022
    Location
    India
    MS-Off Ver
    Home 2021
    Posts
    896

    Re: Create excel files based on requirement and email automatically?

    @zbor

    Oh yes. It does work Thanks a bunch.

    Just 2 queries.

    Text in red is actually hyperlink but not sure how to keep it as hyperlink in macro. Can you guide?

    Also, i dont want mail to be sent automatically. It should be all ready but i should click the send button. So which line needs to be omitted

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,812

    Re: Create excel files based on requirement and email automatically?

    Quote Originally Posted by rizwanulhasan View Post
    Also, i dont want mail to be sent automatically. It should be all ready but i should click the send button. So which line needs to be omitted
    Try to comment this one and test it:

    Please Login or Register  to view this content.
    Last edited by zbor; 10-16-2024 at 07:01 AM.

  9. #9
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,812

    Re: Create excel files based on requirement and email automatically?

    Here is set log link reference (change it in your code to exact path):

    In comments are made changes:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    01-01-2022
    Location
    India
    MS-Off Ver
    Home 2021
    Posts
    896

    Re: Create excel files based on requirement and email automatically?

    Works perfectly in above file. But problem when i copy same code in original file
    Attached Images Attached Images
    Attached Files Attached Files

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,821

    Re: Create excel files based on requirement and email automatically?

    Usedrange is unreliable (in your workbook it includes a lot of empty rows/columns.) Use:

    Please Login or Register  to view this content.
    in the previous line instead of
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  12. #12
    Forum Contributor
    Join Date
    01-01-2022
    Location
    India
    MS-Off Ver
    Home 2021
    Posts
    896

    Re: Create excel files based on requirement and email automatically?

    Perfect. Thanks a bunch to all

+ 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 create VBA code to automatically print excel pages and send via email?
    By Keegan1116 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-12-2024, 11:19 AM
  2. [SOLVED] Macro to Create an Email and attach files based on name in Hyperlink
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-01-2023, 06:27 AM
  3. [SOLVED] Email (outlook) excel files to specified recipients based upon the file name
    By monkeypants in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2016, 11:13 AM
  4. Email automatically from Excel based on condition
    By jorjacman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-04-2015, 04:55 PM
  5. Replies: 0
    Last Post: 04-04-2012, 09:21 AM
  6. Automatically print many PDF-files based on a list in excel?
    By dirigenten in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-08-2006, 04:04 AM
  7. automatically send email in excel based on value/macro guru stuff
    By Michael A in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2005, 05:05 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