|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
保留了大部分原代码,便于楼主理解。
- Sub ykcbf() '//2024.4.7
- With Sheets("表2")
- yr = .[j1]
- mm = .[j2]
- .UsedRange.Offset(2).Clear
- End With
- ar = Sheets("表1").UsedRange
- ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
- For i = 2 To UBound(ar)
- If Val(ar(i, 1)) = yr Then
- If Val(ar(i, 2)) = mm Then
- r = r + 1
- For j = 1 To UBound(ar, 2)
- br(r, j) = ar(i, j)
- Next
- End If
- End If
- Next
- If r Then
- With Sheets("表2").Range("a3").Resize(r, UBound(br, 2))
- .Value = br
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .Borders.LineStyle = 1
- End With
- Else
- MsgBox "没有相应的记录!"
- Exit Sub
- End If
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|