Hi akhtar_shah
Make a unique of each customers so u can verify easily.
Public Sub 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
Sheets("CustomerDetails").Select
Range("A1").Select
lastrow = Range(Selection, Selection.End(xlDown)).Count
Sheets("BasicInvoice").Select
'Range("A1").Select
' 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 nextrow
'we map excel worksheet data to the variables
ActiveSheet.Range("C8").Value = Sheets("CustomerDetails").Cells(r, 1).Value
ActiveSheet.Range("C9").Value = Sheets("CustomerDetails").Cells(r, 2).Value
ActiveSheet.Range("C10").Value = Sheets("CustomerDetails").Cells(r, 3).Value & ", " _
& Sheets("CustomerDetails").Cells(r, 4).Value & " " _
& Sheets("CustomerDetails").Cells(r, 5).Value
ActiveSheet.Range("L8").Value = Sheets("CustomerDetails").Cells(r, 6).Value
ActiveSheet.Range("L9").Value = Sheets("CustomerDetails").Cells(r, 7).Value
ActiveSheet.Range("G8").Value = Sheets("CustomerDetails").Cells(r, 8).Value
ActiveSheet.Range("G10").Value = Sheets("CustomerDetails").Cells(r, 9).Value
ActiveSheet.Range("I14").Value = Sheets("CustomerDetails").Cells(r, 10).Value
ActiveSheet.Range("K14").Value = Sheets("CustomerDetails").Cells(r, 11).Value
ActiveSheet.Range("B14").Value = Sheets("CustomerDetails").Cells(r, 12).Value
Application.DisplayAlerts = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Users\Akhtar\Desktop\Experiment\" & Sheets("CustomerDetails").Cells(r, 1).Value & "_Invoice.PDF", _
OpenAfterPublish:=True
Next r
End Sub
Bookmarks