|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
试着写了一个
Sub test()
Dim i As Integer, rng As Range, arr, sht1 As Worksheet, sht4 As Worksheet
Set sht1 = Sheets("sheet1")
Set sht4 = Sheets("Sheet4")
Set rng = sht4.Range("A1048576").End(3)
arr = sht1.Range("A8:B" & sht1.Range("A1048576").End(3).Row).Value
For i = 1 To UBound(arr, 1)
sht1.Cells(5, 1).Value = arr(i, 1)
sht1.Cells(5, 2).Value = arr(i, 2)
Set rng = sht4.Range("A1048576").End(3)
If rng = "" Then
rng.Value = sht1.Cells(7, 3).Value
rng.Offset(1, 0).Value = sht1.Cells(7, 4).Value
Else
rng.Offset(1, 0).Value = sht1.Cells(7, 3).Value
rng.Offset(2, 0).Value = sht1.Cells(7, 4).Value
End If
Next
End Sub |
评分
-
1
查看全部评分
-
|