EM muốn xuất mảng dữ liệu từ "M2": "S " & dòng cuối có dữ liệu của sheet " Loc KQ" sang sheet " CA NO" . sau đó xuất vừa tạo thành và lưu thành file excel mới với tên ô B3 ( sheet "loc KQ").
Anh/ chị giúp em với
------đoạn code--" module 3 theo file đính kèm
Sub Ca_xuat()
Dim arr(), kq() As Boolean, i As Long, a As Long, lr As Long
Dim shNguon As Worksheet, shBc As Worksheet
Set shNguon = ThisWorkbook.Sheets("LOC KQ")
Set shBc = ThisWorkbook.Sheets("CA NO")
With shNguon
lr = .Range("I" & Rows.Count).End(xlUp).Row ' tim dong cuoi
arr = .Range("m2: s" & lr).Value
ReDim kq(1 To UBound(arr, 1), 1 To 7)
For i = 1 To UBound(arr, 1)
a = a + 1
kq(a, 1) = arr(i, 1)
kq(a, 2) = arr(i, 2)
kq(a, 3) = arr(i, 3)
kq(a, 4) = arr(i, 4)
kq(a, 5) = arr(i, 5)
kq(a, 6) = arr(i, 6)
kq(a, 7) = arr(i, 7)
Next i
End With
With shBc
If a > 0 Then
.Range("a9").Resize(a, 7).Value = kq
End If
End With
End Sub
Anh/ chị giúp em với
------đoạn code--" module 3 theo file đính kèm
Sub Ca_xuat()
Dim arr(), kq() As Boolean, i As Long, a As Long, lr As Long
Dim shNguon As Worksheet, shBc As Worksheet
Set shNguon = ThisWorkbook.Sheets("LOC KQ")
Set shBc = ThisWorkbook.Sheets("CA NO")
With shNguon
lr = .Range("I" & Rows.Count).End(xlUp).Row ' tim dong cuoi
arr = .Range("m2: s" & lr).Value
ReDim kq(1 To UBound(arr, 1), 1 To 7)
For i = 1 To UBound(arr, 1)
a = a + 1
kq(a, 1) = arr(i, 1)
kq(a, 2) = arr(i, 2)
kq(a, 3) = arr(i, 3)
kq(a, 4) = arr(i, 4)
kq(a, 5) = arr(i, 5)
kq(a, 6) = arr(i, 6)
kq(a, 7) = arr(i, 7)
Next i
End With
With shBc
If a > 0 Then
.Range("a9").Resize(a, 7).Value = kq
End If
End With
End Sub