Results 1 to 2 of 2

Macro that creates invoices - Please help!!!!

Threaded View

  1. #1
    Registered User
    Join Date
    05-12-2015
    Location
    new york, usa
    MS-Off Ver
    2013
    Posts
    1

    Macro that creates invoices - Please help!!!!

    I am trying to make a macro that takes the names and details of clients from the data, then creates a separate PDF invoice for each client and emails it to them using outlook ( or any email server for that matter)
    I got the template for an invoice. I also watched a video on youtube that showed how to make invoices from excel and how to feed raw data into an invoice template. However, I am pretty much lost after that and the video is of no help either. I am looking for help regarding:

    "How to make a separate PDf invoice for each client and email it to them." Here's my code:

    Public idk()


    'First we define a few variables to capture data from our Excel worksheet
    Dim customername As String
    Dim customeraddress As String
    Dim invoicenumber As Long
    Dim r As Long
    Dim mydate As String
    Dim path As String
    Dim myfilename As String

    'our last row of data in the worksheet is defined
    lastrow = Sheets("CustomerDetails").Range("A" & Rows.Count).End(xlUp).Row

    ' we start at row 2 since the first row contains headers
    r = 2

    'Looping process starts
    For r = 2 To lastrow

    'If the value under the header ‘Note’ is done then the data in the row is not processed and jump to the label next row

    'we map excel worksheet data to the variables

    customername = Sheets("CustomerDetails").Cells(r, 1).Value
    customeraddress = Sheets("CustomerDetails").Cells(r, 2).Value
    customercity = Sheets("CustomerDetails").Cells(r, 3).Value
    customerstate = Sheets("CustomerDetails").Cells(r, 4).Value
    customerzip = Sheets("CustomerDetails").Cells(r, 5).Value
    invoicenumber = Sheets("CustomerDetails").Cells(r, 6).Value
    invoicedate = Sheets("CustomerDetails").Cells(r, 7).Value
    phone = Sheets("CustomerDetails").Cells(r, 8).Value
    Email = Sheets("CustomerDetails").Cells(r, 9).Value
    MonthlyPayment = Sheets("CustomerDetails").Cells(r, 10).Value
    discount = Sheets("CustomerDetails").Cells(r, 11).Value
    PolicyNumber = Sheets("CustomerDetails").Cells(r, 12).Value


    Application.DisplayAlerts = False
    ActiveWorkbook.Sheets("BasicInvoice").Activate


    ' now we map the variables to the invoice worksheet data
    ActiveWorkbook.Sheets("BasicInvoice").Range("C8").Value = customername
    ActiveWorkbook.Sheets("BasicInvoice").Range("C9").Value = customeraddress
    ActiveWorkbook.Sheets("BasicInvoice").Range("C9").Value = customercity
    ActiveWorkbook.Sheets("BasicInvoice").Range("G8").Value = phone
    ActiveWorkbook.Sheets("BasicInvoice").Range("G10").Value = Email
    ActiveWorkbook.Sheets("BasicInvoice").Range("i14").Value = MonthlyPayment

    'Make a PDF of the Invoice
    ChDir "C:\Users\Akhtar\Desktop"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\Akhtar\Desktop\Experiment", OpenAfterPublish:=True




    'our label next row. Labels have a colon after their name

    Nextrow:

    Next r


    End Sub




    With this code, I am only able to make one PDF invoice. I need a way to tell excel that I want a separate invoice for all the clients listed.
    IDK if I am explaining this well. If you're confused let me know.

    I have attached my excel file as well

    Here's a link of the video i mentioned above: http://www.exceltrainingvideos.com/u...ting-with-vba/
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 01-14-2013, 01:44 PM
  2. [SOLVED] macro that creates new sheets for changes in value
    By Steve99999 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-03-2012, 10:43 AM
  3. Can you create a macro that creates a macro and saves to a worksheet?
    By rob.parson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2012, 07:49 PM
  4. Replies: 11
    Last Post: 02-13-2012, 06:10 PM
  5. Replies: 3
    Last Post: 12-15-2009, 10:22 AM

Tags for this Thread

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