-
Notifications
You must be signed in to change notification settings - Fork 0
/
Creature.txt
39 lines (31 loc) · 1.09 KB
/
Creature.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Sub RunSELECT()
Dim cn As Object, rs As Object, output As String, sql As String
Dim sType As String
Dim count As Integer
sType = "Creature"
testColor = "{W}"
testRarity = "2"
'---Connecting to the Data Source---
Set cn = CreateObject("ADODB.Connection")
With cn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.ConnectionString = "Data Source=" & ThisWorkbook.Path & "\" & ThisWorkbook.Name & ";" & _
"Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
.Open
End With
'---Run the SQL SELECT Query---
sql = "SELECT Count(*) FROM [Sheet1$] " & _
"WHERE [Rarity2] > " & testRarity & " AND [COLOR_IDENTITY]='" & testColor & "'" & " AND [SimpleType] = " & Chr$(39) & sType & Chr$(39)
Set rs = cn.Execute(sql)
Do
output = output & rs(0) '& ";" & rs(1) & ";" & rs(2) & vbNewLine
Debug.Print rs(0); '";" & rs(1) & ";" & rs(2)
rs.Movenext
Loop Until rs.EOF
MsgBox output
'---Clean up---
rs.Close
cn.Close
Set cn = Nothing
Set rs = Nothing
End Sub