[英]Paste multiple string variables across multiple cells in Excel via VBA
我正在尝试将Excel中的多个变量复制到剪贴板。 我的目标是粘贴这些变量时,会将每个变量粘贴到其自己的单元格中。
Public height As Integer
Public width As Integer
Public top As Integer
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copy the dimensions to the clipboard
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub CopyDimensions()
Dim txt As String
txt = height & "|" & width & "|" & top
' Place text into the Clipboard
' From http://www.thespreadsheetguru.com/blog/2015/1/13/how-to-use-vba-code-to-copy-text-to-the-clipboard
ClipBoard_SetData txt
End Sub
我刚刚使用管道来区分每个变量。
现在,当我粘贴剪贴板内容时,它仅出现在一个单元格中。 有没有办法使每个由管道分隔的整数进入其自己的单元格?
ClipBoard_SetData
函数可以在这里找到。 这是Microsoft的修复程序。
通过使用选项卡而不是管道来解决此问题:
txt = height & vbTab & width & vbTab & top
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.