[英]how to extract particular cell to my SQL in EXCEL
Here is a example table in Excel: 这是Excel中的示例表:
ID Name Account
1 Jon 001
2 Snow 002
3 Alive 003
I want to create a SQL according to account. 我想根据帐户创建一个SQL。 It looks like, 看起来像,
SELECT * FROM CUSTOMER_TABLE WHERE ACCOUNT=' ';
Is it possible to make system could fulfill ACCOUNT=' '
? 是否有可能使系统满足ACCOUNT=' '
? Like system could input each value automatically. 像系统可以自动输入每个值。
It should like WHERE ACCOUNT='C1', ACCOUNT='C2', ACCOUNT='C3'...
它应该是WHERE ACCOUNT='C1', ACCOUNT='C2', ACCOUNT='C3'...
I assume you copied your accounts into a range like Range("E1:E10")
. 我假设您将帐户复制到了Range("E1:E10")
类的Range("E1:E10")
内。 Then you can use a for loop to change accounts for every turn. 然后,您可以使用for循环更改每个回合的帐户。 Change your Query as, 将您的查询更改为
SQL_Query = "Select * From Customer_Table Where Account ="
then try a For Loop
. 然后尝试一个For Loop
。
Dim Query as String
For i = 1 to 10
Query = SQL_Query & Cells(i,4).value
'Do your query here.
'Be careful about that your results should be copied under the last row.
'Otherwise only the last one will be shown.
Next
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.