|
![](https://clubstatic.excelhome.net/image/common/ico_lz.png)
楼主 |
发表于 2015-10-28 09:37
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
没能想到简单的VBA,现自己写出了相关代码,已能解决:
Private Sub CommandButton1_Click() '记账
m = Format(Month(Sheets("工资单").Cells(3, 4)), "00") & Format(Sheets("工资单").Cells(2, 3), "0000") '提取编码
x = Sheets("数据库").Range("a:a").Find(m).Row '符合编码的首行
n = Application.WorksheetFunction.CountIf(Worksheets("数据库").[A:A], m) '符合编码的记录行数
L = x + n - 1 '计算末位的行数
For i = x To L '填写审核人和日期
Sheets("数据库").Cells(i, 20) = Sheets("工资单").Cells(256, 4)
Sheets("数据库").Cells(i, 21) = Sheets("工资单").Cells(1, 3)
Next i
End Sub
不知老师们是否有更好的代码,比如用数组的方法 |
|