如何在VBA Excel中提取某些行并重复该过程 [英] How to Extract certain rows and repeating the process in VBA Excel
问题描述
嘿伙计,
我想要从Excel文件中提取某些行并将它们放在一个工作表上,并重复该过程数百次,这样我就有数百个工作表,每个工作表包含来自源Excel文件的相关
行。
这是我能够提出的:
sub Extract ()
设置范围2 =范围(" A8:F20,A21:F31,A32: F47,A48:F60,A61:F71,A72:F87")
range2.Copy
Set NewSheet = Worksheets.Add
ActiveCell.PasteSpecial Paste:= xlPasteValues
对于I = 1到20'重复提取的数据
range2.Copy
Set NewSheet = Worksheets.Add
ActiveCell.PasteSpecial Paste:= xlPasteValues
Next我
结束次
Set range2 = Range("A8:F20, A21:F31, A32:F47, A48:F60, A61:F71, A72:F87") range2.Copy Set NewSheet = Worksheets.Add ActiveCell.PasteSpecial Paste:=xlPasteValues For I = 1 To 20 'to repeat the extracted data range2.Copy Set NewSheet = Worksheets.Add ActiveCell.PasteSpecial Paste:=xlPasteValues Next I End Sub
输出:我的范围合并了extr将文件处理成重复的表格。但是我想将每个范围提取到一个新的表格中(即总共6张),然后可以重复几次。
Output: My range combined the extracted files into a sheet which is the repeated. But I would like to extract each range into a new sheets (i.e 6 sheets in total) which can then be repeated severally
推荐答案
这不是Excel VBA论坛。 您需要将VBA问题发布到Excel VBA论坛。
This is not an Excel VBA forum. You need to post VBA questions to the Excel VBA forum.
这篇关于如何在VBA Excel中提取某些行并重复该过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!