I'm trying to make my life at work a bit easier, but I can't get past the basic VBA issues.
After some research I got to this point:
Sub testowe()
Dim wbk1 As Workbook
Dim wbk2 As Workbook
Dim y As Variant
Dim sht As Worksheet
Set wbk1 = ActiveWorkbook
Set wbk2 = Workbooks.Open("U:\ZBROJARNIA\_WSPOLNE\test.xlsx")
Set sht = wbk2.Worksheets("Sheet1")
y = wbk2.sht.Columns("A").Find("", Cells(Rows.Count, "A"), xlValues, xlWhole, , xlNext).Row
End Sub
To begin I need to find the last empty cell in "test.xlsx" to start there. All of this while having only another workbook active (I want to reduce the ammount on interaction as much as possible ie. opening the test.xlsx workbook by myself). But somehow it doesn't work.
Having an error of "Object not supporting this property or method". It's probably some basic reference mistake, but I've got no idea how to handle it.
Edit: After a suggestion below I changed the y = to
y = sht.Columns("A").Find("", sht.Cells(sht.Rows.Count, "A"), xlValues, xlWhole,, xlNext).Row
But I'm getting a "Subscript out of range" error.
Edit2:
Changed the sht reference to
Set sht = wbk2.Sheets(1)
And it works ! Thanks for the tips below.
Edit3: Okay, not everything works... Current code looks like this:
Sub testowe()
Dim wbk1 As Workbook
Dim wbk2 As Workbook
Dim y As Variant
Dim sht As Worksheet
Dim LA As Integer
Dim Z As Variant
Set wbk1 = ActiveWorkbook
Set wbk2 = Workbooks.Open("U:\ZBROJARNIA\_WSPOLNE\Przeroby-podsumowanie.xlsx")
Set sht = wbk2.Sheets(1)
y = sht.Columns("A").Find("", sht.Cells(sht.Rows.Count, "A"), xlValues, xlWhole, , xlNext).Row
x = Application.Sheets.Count
LA = 2
Do While LA < x
Z = wbk1.Sheets(LA).Cell("C10").Value
LA = LA + 1
Loop
End Sub
Getting an automation error - have no idea what it means.