3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ボタンの左の値をクリップボードに入れる

Last updated at Posted at 2015-02-21

要件

  • 値をマウス操作だけでコピーしたい。
  • 書式や改行コードは不要。
  • マクロ修正せずにコピペで利用者が対象を増やしていきたい。

スクリーンショット 2015-02-22 8.08.00.png

マクロ

copy_hidari
Sub copy_hidari()
'
' copy_hidari Macro
'

    Dim xy, hidari
    ' ボタンの座標を取得
    xy = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address
    ' ボタンの左の値を取得
    hidari = Range(xy).Offset(0, -1).Value
    ' ボタン押したかわかるように、左のセルを選択しとく。
    Range(xy).Offset(0, -1).Select
    
    ' 値をクリップボードにコピー
    Dim myDO As New DataObject
    myDO.SetText hidari
    myDO.PutInClipboard

End Sub

後はこれを画像のようにボタン設置すれば良い。

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?