vba 在大型 Excel 文件的列中复制粘贴重复值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22722032/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Copy pasting repeated values in a column of a large excel file
提问by Chicken_Hawk
I'm stuck on a problem and would love some help.
我被困在一个问题上,希望得到一些帮助。
Here is what I'm working with now:
这是我现在正在使用的:
What I'd like is for column B,C, & D to copy in the blank rows below it until it reaches a new client like so:
我想要的是 B、C 和 D 列在它下面的空白行中复制,直到它到达一个新客户端,如下所示:
Any and all help is very much appreciated.
非常感谢任何和所有帮助。
Thanks
谢谢
回答by Dmitry Pavliv
Non VBA solution:
非 VBA 解决方案:
Select entire range with your data. Press CTRL+Gand select Special...
用您的数据选择整个范围。按CTRL+G并选择特殊...
Choose Blanksand press OK
选择空白并按确定
You would get result as in image below. With selected cellstype =
and press ↑key. Press CTRL+ENTER
你会得到如下图所示的结果。选择单元格类型=
并按下↑键。按CTRL+ENTER
Result:
结果:
Now if you want you can copy result and make PasteSpecial-->Paste Values
现在,如果您愿意,您可以复制结果并制作PasteSpecial-->Paste Values
VBA solution:
VBA解决方案:
Sub test()
Dim rng As Range, ar As Range
On Error Resume Next
Set rng = Range("A2:D20").SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If Not rng Is Nothing Then
rng.FormulaR1C1 = "=R[-1]C"
rng.Calculate
For Each ar In rng.Areas
ar.Value = ar.Value
Next
End If
End Sub