I have a "My Quote" template workbook which has a quote number in cell "I1" of the "Quote" sheet.
Upon opening that workbook I want to go to another (unopened) "Quote List" workbook, find the last row and look at the last quote number in column A of the "Quotes" sheet.
I then wish to add 1 to it and enter it in cell "I1" of the already open "My Quote" workbook (I.E. find the last quote number, say 3001 in the "Quotes" sheet of the "Quote List" workbook, and enter 3002 in the "Quote" sheet of the "My Quote" workbook).
Below errors on
Set wb1 = Workbooks("C:\Quotes\Quote List.xlsx")
The path and spreadsheet name / type are correct.
I am using Excel from Office 2019.
Sub Workbook_Open()
Dim wb1 As Workbook 'Quote List
Dim wb2 As Workbook 'My Quote
Dim ws1 As Worksheet 'Quotes
Dim ws2 As Worksheet 'Quote
Set wb1 = Workbooks("C:\Quotes\Quote List.xlsx")
Set ws1 = wb1.Sheets("Quotes")
Set wb2 = ActiveWorkbook
SourcePath = "C:\Quotes"
Set ws2 = wb2.Sheets("Quote")
lastrow = ws1.Cells(ws.Rows.Count, "A").End(xlUp).Row
ws2.Range("I1").Value = ws1.Range(lastrow).Value + 1
End Sub
Set wb1 = Workbooks.Open("C:\Quotes\Quote List.xlsx").