|
楼主 |
发表于 2009-1-14 15:16
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
请再看看
根据zez的模板,
出来后还是有问题,我想给营销员列加入固定值
可结果这一列没有值
n = Application.WorksheetFunction.CountA(Range("B6:B10"))
For i = 6 To n + 5
Sql = "select * from " & myTable _
& " where 营销员='" & ws.Cells(3, 8).Value & "'" _ ’向指定向固定的H3值,其它B6:G10
& " and 日期=#" & Format(ws.Cells(i, 2).Value, "yyyy-mm-dd") & "#" _
& " and 地点及方式='" & ws.Cells(i, 3).Value & "'" _
& " and 访问对象='" & ws.Cells(i, 4).Value & "'" _
& " and 洽谈内容='" & ws.Cells(i, 5).Value & "'" _
& " and 结果成果='" & ws.Cells(i, 6).Value & "'" _
& " and 看法建议='" & ws.Cells(i, 7).Value & "'"
Set rs = New ADODB.Recordset ’以下部分干嘛,不是在上面已经赋值了吗
rs.Open Sql, cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount = 0 Then
rs.AddNew
For j = 1 To rs.Fields.Count
rs.Fields(j - 1) = ws.Cells(i, j).Value ‘这样一来access的第一个值成了A列的,出来的是空白
Next j
rs.Update
Else
For j = 1 To rs.Fields.Count
rs.Fields(j - 1) = ws.Cells(i, j).Value
Next j
rs.Update
End If
Next i
最后请给逐行注释一下吧,谢谢 |
|