Excel Server

Hello All,

When I am grabbing sql server table via vba into a excel, its only grabbing the data rows but Not the column header row - how can i get it so that the data row comes with the headers row too? can someone assist..

Rayne
RayneAsked:
Who is Participating?
 
Rgonzo1971Connect With a Mentor Commented:
Hi,

pls try

With rsRecordSet
     For Idx = 1 To .Fields.Count
         ActiveSheet.Cells(1, Idx) = .Fields(Idx - 1).Name
     Next
End With
ActiveSheet.Range("A2").CopyFromRecordset rsRecordSet

Open in new window

Regards
0
 
RayneAuthor Commented:
thank you Rgonzo1971 :)
0
All Courses

From novice to tech pro — start learning today.