PDA

View Full Version : Display CopyFromRecordset result vertically



NetHead21
12-08-2018, 04:33 AM
Hello and Good day Masters, I have this vba code that copies my student grades from access database then display or print it on my excel file. It prints the grades horizontally however is it possible to display or print the output vertically?

Here's the current output


99
98
79
95
95
90
99
95
96



And I want to achieve something like this one


99


98


79


95


95


90


99


95


96




Here's my code:



Set db = OpenDatabase(DBLoc)
'MsgBox "Hello " & search
SQL = "SELECT [Dance (PE3)], [Intro to Philo], EmTech, Entrep, Pilipino, [Practical Research 1], Animation, [Discip and Ideas], [Org & Manage]"
SQL = SQL & "FROM [G12B Student Information]"
SQL = SQL & "WHERE LASTNAME = '" & search & "'"


'Execute query and populate the recordset
Set rs = db.OpenRecordset(SQL, dbOpenSnapshot)

'Copy recordset to variables then to spreadsheet
Application.StatusBar = "Writing to spreadsheet..."

If rs.RecordCount = 0 Then
MsgBox "Name not found in the database", vbInformation + vbOKOnly, "No Data"
GoTo SubExit
Else
rs.MoveLast
recCount = rs.RecordCount
rs.MoveFirst

End If

xlSheet.Range("BQ13").CopyFromRecordset rs




Any suggestions will be greatly appreciated. Thank you very in advance.

Leith Ross
12-08-2018, 02:08 PM
Cross-posted Here (https://www.excelforum.com/excel-programming-vba-macros/1255829-display-copyfromrecordset-result-vertically.html) at Excel Forum.

NetHead21
12-08-2018, 10:54 PM
My apologies I was not aware of cross-posting rules, anyway thank you for responding.