I'd like to begin by stating that I am able to successfully query my sharepoint list and import data based on a single condition.

My issue:

  • In excel, I have a list of unique ID's in column A and column B is titled "Name.
  • The above setup resides on a sharepoint list which contains the name.
  • I want vba to create a 'query array' that contains all ID's under column A and then query the sharepoint list to extract the "Name" and place it in column B.

My code that extracts based on a single condition

dim usr as string
usr = "X12345"
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
With cn
.ConnectionString = sConn
End With
sSQL = "SELECT [Name] FROM [splistname] WHERE [emp_id]= '" & usr & "'"
rs.Open sSQL, cn, adOpenStatic, adLockOptimistic
Sheet3.Range("b5").CopyFromRecordset rs

I've tried putting this in a "For" loop, but I have very limited knowledge on how to achieve this or even if it is possible.

Hoping someone can point me in the right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.