Excel 宏 - 将所选内容粘贴到 Word 中
我正在使用下面的代码
iMaxRow = 200
" Loop through columns and rows"
For iCol = 1 To 3
For iRow = 1 To iMaxRow
With Worksheets("GreatIdea").Cells(iRow, iCol)
" Check that cell is not empty."
If .Value = "" Then
"Nothing in this cell."
"Do nothing."
Else
" Copy the cell to the destination"
.Copy Destination:=Worksheets("Sheet2").Cells(iRow, iCol)
End If
End With
Next iRow
Next iCol
上面的代码仅适用于同一个 Excel 工作表。我想扩展它以便将其粘贴到Word文档中。我认为这是与;
appWD.Selection.PasteSpecial
但问题是,我还没有做出任何选择。代码很好,只是需要编辑 Copy Destination:=Worksheets("Sheet2").Cells(iRow, iCol)
。
感谢您的帮助!
I'm using the code below
iMaxRow = 200
" Loop through columns and rows"
For iCol = 1 To 3
For iRow = 1 To iMaxRow
With Worksheets("GreatIdea").Cells(iRow, iCol)
" Check that cell is not empty."
If .Value = "" Then
"Nothing in this cell."
"Do nothing."
Else
" Copy the cell to the destination"
.Copy Destination:=Worksheets("Sheet2").Cells(iRow, iCol)
End If
End With
Next iRow
Next iCol
The code above is only applicable on the same excel sheet. I would like to extend it so it pastes into a word document. I presume it's something with;
appWD.Selection.PasteSpecial
But the problem is, I haven't made any selections. The code is good, just Copy Destination:=Worksheets("Sheet2").Cells(iRow, iCol)
needs to be edited.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)