跳过非空单元格以粘贴特殊数据
仅当范围 (a3:M3) 为空时,我才想将工作表“SL”中的范围 (a3:M3) 中的数据复制到工作表“EL”中的范围 (a3:m3) 中。否则将所选数据复制到下一行 (a4:m4)。
下面是我尝试解决的代码..但它不起作用...请帮助
Range("C9:G10").Select
Selection.Copy
Sheets("EL").Select
For n = 1 To n = 100
If Cells(n, 2).Value <> "" Then
Cells(n + 1, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Next n
I want to copy data from range (a3:M3) in worksheet "SL" to range (a3:m3) in worksheet "EL" only if range (a3:M3) is empty. Else to copy the selected data to the next row (a4:m4).
Below is the code i tried to work out ..but its not working...plz help
Range("C9:G10").Select
Selection.Copy
Sheets("EL").Select
For n = 1 To n = 100
If Cells(n, 2).Value <> "" Then
Cells(n + 1, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Next n
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码中有一些点我不明白:
C9:G10
?n=1到100
的循环?For n = 1 To n = 100
并不像您期望的那样工作 ->将其替换为For n = 1 To 100
。)这是我对您的问题的解决方案:
There are some points in your code I do not understand:
C9:G10
?n=1 to 100
?For n = 1 To n = 100
does not work as you might expect -> replace it withFor n = 1 To 100
.)Here is my solution to your problem: