Help us understand the problem. What is going on with this article?

セルの値だけクリップボードにコピーするマクロ

More than 5 years have passed since last update.

Excelのセルをコピーして数値しか入らないInputBoxに貼り付けられないと言われた。
数値しか入らないInputBoxは、空白が入ると貼り付けが出来ない様子。

毎回別の箇所にコピーして末尾の空白と改行を消して貼り付けるよう言ったが面倒臭がられたので調べてみた。

DataObjectを使えるようにする手順

  1. Visual Basicから「挿入>ユーザーフォーム」をクリック。

1.png

2.「ツール>参照設定」をクリック。

2.png

  1. 「Mirosoft Forms 2.0 Object Library」にチェックが付いていることを確認。

3.png

マクロ

4.以下コードをマクロに登録。

Sub copy_e6()
'
' copy_e6 Macro
'

    Dim myDO As New DataObject
    myDO.SetText Range("E6").Value
    myDO.PutInClipboard

End Sub

5.ボタンとか配置して上のマクロを割り当てると完了。
ボタンをクリックしてE6のValueがクリップボードに入ることを確認。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした