Excel:当数据验证被更改时,将该值复制到特定的单元格中

时间:2022-12-23 19:44:13

On sheet 1 Cell 15 I have a cell which is a data validation to choose a cluster, I would like it so when I select a value from the drop-down it copies & pastes to another cell in another sheet which is read by formulas.

在表1单元格15中,我有一个单元格,它是一个用于选择集群的数据验证,我希望它是这样的,所以当我从下拉列表中选择一个值时,它会将它复制并粘贴到另一个单元格中的另一个单元格中,该单元格可以通过公式读取。

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "I15" Then
    With Sheets("Team Holiday Calender").Cells(2, "C") '.End(xlup)(2)
    Sheets("Front").Range("I15").Copy
            .PasteSpecial xlPasteValidation
            Application.CutCopyMode = False

    End If

End Sub

Is what i currently have, but it doesn't do the job.

这是我目前所拥有的,但它并不能起到作用。

Am i making this too hard for myself?

这对我自己来说太难了吗?

1 个解决方案

#1


1  

Try it as,

试一试,

Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address(0, 0) = "I15" Then
        With Sheets("Team Holiday Calender")
            .Cells(2, "C") = Target.Value
        end with
    End If

End Sub

Direct .Value transfer does not copy formatting along like a Copy & Paste does but you should be able to accommodate for that or switch to a Copy & Paste.

直接。value transfer不像复制和粘贴那样复制格式,但是您应该能够适应它,或者切换到复制和粘贴。

#1


1  

Try it as,

试一试,

Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address(0, 0) = "I15" Then
        With Sheets("Team Holiday Calender")
            .Cells(2, "C") = Target.Value
        end with
    End If

End Sub

Direct .Value transfer does not copy formatting along like a Copy & Paste does but you should be able to accommodate for that or switch to a Copy & Paste.

直接。value transfer不像复制和粘贴那样复制格式,但是您应该能够适应它,或者切换到复制和粘贴。