How to find the lasrow in a table which doesn't have hyperlinks

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.

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:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top