Last active
August 29, 2015 13:59
-
-
Save zhimiaoli/10695594 to your computer and use it in GitHub Desktop.
将选择的内容每一个单元格用“|”分开
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub formattable() | |
Dim rgname As Range | |
Set rgname = Application.InputBox("选择需要输出的区域", "选择区域", Type:=8) | |
rownow = rgname.Row | |
For Each cell In rgname | |
If cell.Row <> rownow Then | |
rownow = rownow + 1 | |
result = result & vbNewLine & application.WorksheetFunction.Clean(cell.Value) & "|" | |
Else | |
result = result & application.WorksheetFunction.Clean(cell.Value) & "|" | |
End If | |
Next cell | |
' Debug.Print result | |
on error goto nomsforms | |
Dim clip As MSForms.DataObject | |
Set clip = New MSForms.DataObject | |
clip.SetText result | |
clip.PutInClipboard | |
nomsforms: | |
msgbox "不能复制到剪贴板,请按ALT+F11,然后按Ctrl + G查看结果" | |
debug.print result | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment