none
Run-time error 91 object variable or with block variable not set RRS feed

  • Question

  • I know this is a common problem and there are many posts, but my code is below

    when executing error is on red line "Run-time error 91 object variable or with block variable not set"

    Pls help me

    Sub Central_Risk()

        Sheets("Data Signature").Select

        Range("A1").Select

        With Selection.ListObject.QueryTable

            .Connection = Array( _

            "OLEDB;Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=;Initial Catalog=;Data Source=;" _

            , _

            "Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=NGD5N2QC3J;Use Encryption for Data=False;Tag wit" _

            , "h column collation when possible=False")

            .CommandType = xlCmdSql

            .CommandText = Array( _

            "Select     distinct

            )

            .Refresh BackgroundQuery:=False

        End With

        Sheets("Pivot TB").Select

        Range("A1").Select

        ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh

    End Sub

    Tuesday, April 30, 2013 8:34 AM