Xin chào cả nhà !
Mình có một đoạn code như sau và muốn chuyển từ sự kiện Private Sub Worksheet_Change(ByVal Target As Range) thành Private Sub Worksheet_Calculate() thì đoạn code dưới đây sẽ được viết lại như thế nào ?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Integer
Dim c As Integer
Dim arr(1 To 1, 1 To 21)
For i = 1 To 1155
If Not Intersect(Target, Range("C" & CStr(i) & ":U" & CStr(i))) Is Nothing Then
r = Target.Row
For c = 1 To 21
arr(1, c) = Cells(r, c).Value
Next
With Sheets(Cells(i,2).Value)
.Range(.Cells(.UsedRange.Rows.Count + 1, 1), .Cells(.UsedRange.Rows.Count + 1, 21)) = arr
End With
End If
Next i
End Sub
Em xin cảm ơn cả nhà !!!
Mình có một đoạn code như sau và muốn chuyển từ sự kiện Private Sub Worksheet_Change(ByVal Target As Range) thành Private Sub Worksheet_Calculate() thì đoạn code dưới đây sẽ được viết lại như thế nào ?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Integer
Dim c As Integer
Dim arr(1 To 1, 1 To 21)
For i = 1 To 1155
If Not Intersect(Target, Range("C" & CStr(i) & ":U" & CStr(i))) Is Nothing Then
r = Target.Row
For c = 1 To 21
arr(1, c) = Cells(r, c).Value
Next
With Sheets(Cells(i,2).Value)
.Range(.Cells(.UsedRange.Rows.Count + 1, 1), .Cells(.UsedRange.Rows.Count + 1, 21)) = arr
End With
End If
Next i
End Sub
Em xin cảm ơn cả nhà !!!