Actuarial Outpost
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Software & Technology
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions

Actuarial Jobs by State

New York  New Jersey  Connecticut  Massachusetts 
California  Florida  Texas  Illinois  Colorado

Thread Tools Search this Thread Display Modes
Old 09-28-2017, 11:05 AM
Freebird's Avatar
Freebird Freebird is offline
Join Date: Dec 2001
Location: Topeka, Kansas
College: Graduated from Ohio State too many years ago to remember
Favorite beer: Newcastle
Posts: 824

Originally Posted by dumples View Post
Not trying to be a jerk, but it would take me longer to put it here than it would take for you to google "Excel VBA CopyFromRecordSet example"
No offense taken, dumples. There are probably a million ways to import into Excel from Access, and so I added CopyFromRecordset to my search string. It was a good suggestion, because I got the following official code below from Microsoft.

Thanks to all for your suggestions!

Sub GetQuery()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim i As Long
Dim wsh As Worksheet
Set dbs = DBEngine.OpenDatabase(Put path and filename here)
Set rst = dbs.OpenRecordset(Put query name here)
Set wsh = Worksheets(Put sheet name here)
For i = 0 To rst.Fields.Count - 1
wsh.Cells(1, i + 1).Value = rst.Fields(i).Name
wsh.Range("A1").Resize(ColumnSize:=rst.Fields.Coun t).Font.Bold = True
wsh.Range("A2").CopyFromRecordset rst
Set rst = Nothing
Set dbs = Nothing
End Sub
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 05:39 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.22996 seconds with 9 queries