I am transitioning from Google Docs to Excel and running int oproblems with equilivent function: specifically the Google Docs: Query()
From googleing around I know that there is no Query in Excel and I have started to make a VBA function to do the same thing but running into trouble
The original Google Docs query =QUERY('GP Referrals 2012-2013'!A15:Z ; "SELECT A, Z WHERE J = 'WH' ORDER BY Z DESC LIMIT 9", 0)
A is a string, Z is a number and J is one of three possible strings. I run this three times with different values in J.
Is there way to do this in Excel. I have a second sheet setup to get put the results of this in.
I have a function started but I am a but stuck as to how to get to the next step. Any help is a appreciated.
Function getTopGPs(clinic As String) As Integer
Dim activeSheet As Object
Set activeSheet = Worksheets(1)
Dim rawRange As Object
Set rawRange = activeSheet.Range("A15:Z65536")
// How can I go from here?
End Function
Based on @chuff's approach, give your data array labels (I chose A
> Z
from A14:Z14) and name the array (A14:Zn) - I chose GParry
.
DATA > Get External Data - From Other Sources, From Microsoft Query, Databases, Excel Files*, OK. Select your workbook name, OK, Table: GParry, Add, Close.
In the list under GParry, double-click on A, J and Z in turn, then click on the SQL button. In SQL statement: change SELECT
to SELECT TOP 9
and append:
WHERE J = 'WH'
ORDER BY Z DESC
OK, OK.
If you want the results back into Excel just select the extract (top left), Edit, Copy and Paste where it suits you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.