|
楼主 |
发表于 2018-7-5 10:28
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
如果是存在两列需要填数值的单元格的话 这个代码要怎么改呢?
Option Explicit
Sub test()
Dim i, arr
With Sheets("sheet1")
arr = .Range("e1:g" & .Cells(Rows.Count, "g").End(xlUp).Row)
For i = 2 To UBound(arr, 1)
If Len(arr(i, 1)) = 0 Then arr(i, 1) = "=VLOOKUP(G" & i & ",Sheet2!$A:$B,2,0)"
Next
.[j1].Resize(UBound(arr, 1)) = arr
arr = .Range("j1:j" & .Cells(Rows.Count, "j").End(xlUp).Row)
.[j1].Resize(UBound(arr, 1)) = arr
End With
End Sub |
|