用于在VBA中循环

时间:2015-08-25 16:07:08

标签: excel vba excel-vba

我有一张类似于此的表格: enter image description here

我想用它来执行SQL服务器中的一些操作。如何创建一个VBA代码(对于循环,更准确)来获得一个类似于:

的字符串
  sql = "select @Name = 'BookA', @price = col next to BookA where date in col D = cell("D1");
         select @Name = 'BookB', @price = col next to BookB where date in col F = cell("D1");..."

例如假设单元格中的日期(“D1”)= '01 .10.2015'

sql应该等于

"select @Name = 'BookA', @price = 101.651; select @Name = 'BookB', @price = 96.291; and so on"

1 个答案:

答案 0 :(得分:1)

将此程序放在标准代码模块中:

{{1}}