sureshxcell
New Member
- Joined
- Jan 14, 2018
- Messages
- 16
Hello,
I am using the following code to export invoices as pdf files. But, I want to run the macro only for the new records in raw-data sheet. Is it possible to frame a logic to find the last used cell in raw-data which has hyperlinks
To be simple I want to run the macro only for the new records in raw-data sheet, which doesn't contain hyperlinks to pdf files.
Thank you
I am using the following code to export invoices as pdf files. But, I want to run the macro only for the new records in raw-data sheet. Is it possible to frame a logic to find the last used cell in raw-data which has hyperlinks
To be simple I want to run the macro only for the new records in raw-data sheet, which doesn't contain hyperlinks to pdf files.
Code:
Option Explicit
Sub InvoiceGeneration()
Dim cfws, ctws As Worksheet
Dim lastrow, i As Long
Dim fileloc, filename, Fname As String
Set cfws = Worksheets("Raw-Data")
lastrow = cfws.Cells(cfws.Rows.Count, "B").End(xlUp).Row + 1
fileloc = "C:\Test\"
For i = 1 To lastrow
[COLOR=#ff0000] If cfws.Range("L" & i).Value = vbNullString Then[/COLOR]
Set ctws = Worksheets("Tax Invoice-2")
Else
Set ctws = Worksheets("Tax Invoice-1")
End If
If cfws.Range("F" & i).Value <> vbNullString And cfws.Range("H" & i).Value <> vbNullString Then
filename = "Invoice -" & cfws.Range("B" & i).Value
ctws.Range("A9").Value = "Invoice No : " & cfws.Range("B" & i).Value
ctws.Range("B23").Value = cfws.Range("H" & i).Value
Fname = fileloc & filename & ".pdf"
[COLOR=#ff0000]cfws.Hyperlinks.Add Anchor:=cfws.Range("M" & i), Address:=Fname, TextToDisplay:=filename[/COLOR]
With ctws
.ExportAsFixedFormat Type:=xlTypePDF, filename:=Fname
End With
End If
Next i
End Sub
Thank you
Last edited: