toandiennuoc123
Thành viên thường trực




- Tham gia
- 7/3/12
- Bài viết
- 239
- Được thích
- 9
Có vẻ như bạn muốn cộng dồn?Trong 1 khoảng thời gian (3s- 5s) nó sẽ tự động xóa ô vừa gõ
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OldVal As Double
On Error Resume Next
Application.EnableEvents = False
If Not Intersect(Range("B2:B15"), Target) Is Nothing Then
If Target.Count = 1 Then
OldVal = CDbl(Target.Value)
Target.Offset(, 1) = Target.Offset(, 1) + OldVal
Target.ClearContents
End If
End If
Application.EnableEvents = True
End Sub
Tại bạn viết sai thôiPro ơi , thêm các cột như thế này có được không ?,khi thêm vào thì không dùng được và hiện dòng màu vàng và xanh.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OldVal As Double
On Error Resume Next
Application.EnableEvents = False
If Not Intersect(Range("AR20:AR29", "AU20:AU29", "AX20:AX29", "BA19:BA30", "BD19:BD30", "BG16:BG30", "BJ19:BJ22"), Target) Is Nothing Then
If Target.Count = 1 Then
OldVal = CDbl(Target.Value)
Target.Offset(, 1) = Target.Offset(, 1) + OldVal
Target.ClearContents
End If
End If
Application.EnableEvents = True
End Sub
Lại phải hỏi thêm Pro rồi, muốn nhập ở ô AF22 rồi được cộng vào ô T33 thì thay đổi (code) ở đoạn nào?. có khoảng 100 ô như vậy(AF22:AO29)và (T33:AC42).(Vẫn ở cùng 1 Sheet có đoạn "code" trên)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OldVal As Double
On Error Resume Next
Application.EnableEvents = False
If Not Intersect(Range("B2:B15"), Target) Is Nothing Then
If Target.Count = 1 Then
OldVal = CDbl(Target.Value)
Target.Offset(, 1) = Target.Offset(, 1) + OldVal
Target.ClearContents
End If
End If
Application.EnableEvents = True
End Sub
PHP:Private Sub Worksheet_Change(ByVal Target As Range) Dim OldVal As Double On Error Resume Next Application.EnableEvents = False If Not Intersect(Range("B2:B15"), Target) Is Nothing Then If Target.Count = 1 Then OldVal = CDbl(Target.Value) Target.Offset(, 1) = Target.Offset(, 1) + OldVal Target.ClearContents End If End If Application.EnableEvents = True End Sub
Anh NDU cho em hỏi qua đoạn code trên
1. Application.EnableEvents = False --> ý nghĩa khi thêm dòng này
2. tại sao phải chuyển đổi dữ liệu bằng hàm CDBL
Cám ơn Anh
Bố trí lại dữ liệu đi bạn ơi... quy luật tùm lum, cuối cùng cũng gần như là chẳng có quy luật gì cả ---> Code nào mà làm việc nỗi đây?Pro xem file đính kèm nhé, nó cũng hơi khó tả