I can't get the code in red below to work. How would I go about coding this section? Is it possible to code this part? "
"lastRow = ws.Cells(ws.Rows.Count, "F").End(xlUp).Row 'Error 1004"
Errors recieved:
"1004" Application-defined or object-defined error
The objective is so it will look in column "F" for total count of data. Next line it adds + 1 and that's the cell it will insert the picture.
Thanks for your help.
"lastRow = ws.Cells(ws.Rows.Count, "F").End(xlUp).Row 'Error 1004"
Errors recieved:
"1004" Application-defined or object-defined error
The objective is so it will look in column "F" for total count of data. Next line it adds + 1 and that's the cell it will insert the picture.
Thanks for your help.
Code:
Public Function AddITARPic()
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
With xlApp
Dim wb As Object
Dim ws As Object
Dim lastRow As Long
Set wb = .Workbooks.Open("D:\Sample.xlsm")
Set ws = wb.Sheets(1)
[COLOR=seagreen]'Code below counts the cells with data and selects the last empty cell[/COLOR]
[COLOR=black]lastRow = ws.Cells(ws.Rows.Count, "F").[/COLOR][COLOR=red]End(xlUp).Row 'Error 1004[/COLOR]
[COLOR=black]Blankcell = lastRow + 1[/COLOR]
ws.Cells(Blankcell, "A").Select
ws.pictures.insert ("D:\sample.png")
xlApp.Visible = True
LinkToFile = False
SaveWithDocument = True
wb.Close
Set xlApp = Nothing
End With
End Function