|
这是FSYYYY老师写的一个宏,我要在新生成的表中插入几列空白列,我录制了一个宏(.CommandText = Array("select """","""",物资编码,"""",计量单位 from [Sheet1$]")),但格式与本程序不一样,请问应如何修改?
Sub fsyyyy()
Sheets("sheet2").Cells.ClearContents
Sheets("sheet2").Range("A1:S1") = Array("序号", "物资编码", "物资名称-规格-型号", "计量单位", "数量", "报价", "报价金额", "网上价格", _
"网价金额", "审核价格", "审核金额", "下浮价格", "核定金额", "供货单位", "报价依据", "备注", "计划编号", "公司批复采购计划时间", "上报价格时间")
r = Sheets("sheet1").[a65536].End(xlUp).Row
Set cn = CreateObject("ADODB.connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & ActiveWorkbook.FullName
Sql = "select 物资编码,[物资名称-规格-型号],计量单位,数量,单价,供货单位,用料库房,公司批复采购计划时间,上报价格时间 FROM [Sheet1$A1:S" & r & "] where [物资名称-规格-型号] like '%水%'"
Sheets("sheet2").Cells(2, 1).CopyFromRecordset cn.Execute(Sql)
Sheets("sheet2").Cells.EntireColumn.AutoFit
cn.Close
Set cn = Nothing
End Sub
[ 本帖最后由 jcrs 于 2009-7-29 08:49 编辑 ] |
|