Compile error: Next without For || VBA

Every For statement with a body must have a matching Next, and every If-Then statement with a body must have a matching End If. Example: You have part of the body of your If statement inside your For i loop, and part of it outside. It has to be either ALL inside or ALL outside. … Read more

Using Excel VBA to run SQL query

Below is code that I currently use to pull data from a MS SQL Server 2008 into VBA. You need to make sure you have the proper ADODB reference [VBA Editor->Tools->References] and make sure you have Microsoft ActiveX Data Objects 2.8 Library checked, which is the second from the bottom row that is checked (I’m using Excel … Read more

VBA Excel “Compile error: Object Required”

I am working on VBA code in excel and i have the following piece of code When I run the code I get a compile error to debug and it reads Object Required. What is it asking me to do? This is a larger piece of the code: