Excelでイベントを作成-セルYの入力後にセルXに値を追加->セルYを消去


-1

基本的に、私がやりたいことは:

列Bに値を挿入するたびに、値を列Aに追加し、列Bを0に設定します。

A    B

23   0

私はこの関数を試しました(Aをuniとして、Bをnew_valueとして渡します)が、うまくいきません...

Function foo(uni, new_value)
    uni = uni + new_value
End Function

1
まあ、それはあなたにいくつかのエラーを与えた場合、私はいくつかの答えがあると確信しています。
クロー

まあ、それはもうエラーを与えませんが、それでも本来の方法で動作していません...私がしようとしていることを達成することさえ可能ですか?
DmitryKvochkin

回答:


0

OK。方法は次のとおりですが、Excelをロードするのが面倒なので、これはテストされていません。

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range

    ' The variable KeyCells contains the cells that will 
    ' cause an alert when they are changed. Edit as needed.
    Set KeyCells = Range("B2:B10")

    If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
      ' This code is only ran when one of the above cells change
      cells(Target.Row, 1).value = cells(Target.Row, 2).value
     cells(Target.Row, 2).value = ""
    End If
End Sub
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.