VBA:从数组复制粘贴范围
我有一个数组,其中包含搜索函数中的单元格位置。我想显示数组中每个位置的结果以及 D:P 列中的后续数据条目。有没有有效的方法来做到这一点?这是我到目前为止所拥有的,但它不是一个工作代码,如果它只选择 D:P 列而不是整行,我会更喜欢它
Dim i1 As Integer
Dim Results1() As Variant
Dim p1results As Range
Dim NextRow as Long
For i1 = LBound(Results1) To UBound(Results1)
Set p1results = Results1(i1).Value
p1results.EntireRow.Copy
Sheets("SearchResult").Select
NextRow = Range("D65536").End(xlUp).Row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
Next i1
I have an array that contains the cell locations form a search function. I would like to display the results of each location in the array along with the subsequent data entry from columns D:P. Is there an efficient way of doing this? This is what I have so far but it is not a working code and i would prefer it if it only selected D:P columns instead of an entire row
Dim i1 As Integer
Dim Results1() As Variant
Dim p1results As Range
Dim NextRow as Long
For i1 = LBound(Results1) To UBound(Results1)
Set p1results = Results1(i1).Value
p1results.EntireRow.Copy
Sheets("SearchResult").Select
NextRow = Range("D65536").End(xlUp).Row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
Next i1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于列 (D:P) 尝试:
假设使用不需要格式,那么最好避免使用副本。复制使用剪贴板,速度很慢。
For columns (D:P) Try:
Assuming use dont need formats then its better to avoid using copy. Copy makes use of the clipboard which is slow.