Mã VBA cho Sheet1:Gửi Anh/Chị,
Em đang tìm phương án cập nhật DataValidation 2 chiều giữa 2 sheet.
Nhờ Anh/Chị hỗ trợ.
Em cám ơn.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws2 As Worksheet
Set ws2 = ThisWorkbook.Sheets("Sheet2")
' Ki?m tra n?u ô thay d?i là DataValidation1
If Not Intersect(Target, Me.Range("E4")) Is Nothing Then
Application.EnableEvents = False
ws2.Range("D3").Value = Target.Value
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Sheets("Sheet1")
' Ki?m tra n?u ô thay d?i là DataValidation2
If Not Intersect(Target, Me.Range("D3")) Is Nothing Then
Application.EnableEvents = False
ws1.Range("E4").Value = Target.Value
Application.EnableEvents = True
End If
End Sub
Dạ, đúng cái em cần.Mã VBA cho Sheet1:
Mã:Private Sub Worksheet_Change(ByVal Target As Range) Dim ws2 As Worksheet Set ws2 = ThisWorkbook.Sheets("Sheet2") ' Ki?m tra n?u ô thay d?i là DataValidation1 If Not Intersect(Target, Me.Range("E4")) Is Nothing Then Application.EnableEvents = False ws2.Range("D3").Value = Target.Value Application.EnableEvents = True End If End Sub
Mã VBA cho Sheet2:
Mã:Private Sub Worksheet_Change(ByVal Target As Range) Dim ws1 As Worksheet Set ws1 = ThisWorkbook.Sheets("Sheet1") ' Ki?m tra n?u ô thay d?i là DataValidation2 If Not Intersect(Target, Me.Range("D3")) Is Nothing Then Application.EnableEvents = False ws1.Range("E4").Value = Target.Value Application.EnableEvents = True End If End Sub