Access VBa - loop through Excel columns
<p>I'm having troubles with looping through Excel file from Access. Here is my code:</p>

<pre><code>     Sub Xceltest()

        Dim XcelApp As Object
        Dim XcelBook As Excel.Workbook
        Dim x, i
        Set XcelApp = CreateObject("Excel.Application")
        XcelApp.ScreenUpdating = False

Set XcelBook = XcelApp.Workbooks.Open("C:\Users\Lucky\Desktop\Test\Sample.xlsx")

   With XcelBook

i = XcelApp.Rows(1).Find(What:="Število", LookIn:=xlValues, Lookat:=xlWhole).Column

x = XcelApp.Range(XcelApp.Cells(1, i), XcelApp.Cells(XcelApp.Rows.Count, i).End(xlUp)).Value

        For i = 2 To UBound(x)
            If Not IsNumeric(x(i, 1)) Then

            ExcelApp.Quit
            Set ExcelApp = Nothing
            MsgBox "This Excel file is not valid"
        : Exit Sub

            End If

        Next i

        End With

        XcelApp.Quit
        XcelApp = Nothing

        End Sub
</code></pre>

<p>Whatever I do, I always get an error in this line:</p>

<pre><code>i = XcelApp.Rows(1).Find(What:="Število", LookIn:=xlValues, Lookat:=xlWhole).Column
</code></pre>

<p>or this one:</p>

<pre><code> For i = 2 To UBound(x)
</code></pre>

<p>Errors are "object doesn't support this property or method"  or "object variable or with block variable not set". How can I fix this, does anybody have a clue ??</p>