简体   繁体   English

在VBA中剪切并粘贴for循环

[英]Cut and paste in a for loop in VBA

I am trying to cut and paste values within a for loop from one list to another. 我正在尝试将for循环中的值从一个列表剪切并粘贴到另一个列表。 I have the range all set up but for some reason the paste keeps failing and I'm not sure why. 我已经设置了所有范围,但是由于某种原因, paste一直失败,并且我不确定为什么。 Here's what I've tried so far: 到目前为止,这是我尝试过的方法:

If WrdArray1(0) = WrdArray2(0) Then
ActiveCell.Cut
With ActiveSheet
Set rng2 = .Range("C" & position)
rng2.PasteSpecial
End With

I am rather new to vba so any help would be greatly appreciated. 我对vba还是比较陌生,因此将不胜感激。

Just use ActiveCell.Cut Destination:=ActiveSheet.Range("C" & position) . 只需使用ActiveCell.Cut Destination:=ActiveSheet.Range("C" & position) That does all in one. 这一切合而为一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM