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




- Tham gia
- 6/12/06
- Bài viết
- 205
- Được thích
- 144
Mã:
[B]Sub dien_du_lieu()[/B]
Dim i, j As Integer: Dim SN As String
Dim dt, dc, ds, str, stc, SR
Dim wsh As Worksheets
SN = InputBox(" nhap ten sheet")
str = 12: stc = 2
dc = Cells(str, stc).End(xlDown).Row
i = str: j = stc
Set SRa = Sheets("DATA").Range("A1:N160")
Set SRb = Sheets("DATA").Range("P1:AE160")
[B][SIZE="2"]Set wsh = Sheets("SN")[/SIZE][/B] '<<=='
wsh.Select
Application.ScreenUpdating = False
If Cells(i, j).Value = "" Then
For j = 2 To 14
Cells(i, j).Value = WorksheetFunction.VLookup(wsh.Name, SRa, j, 0)
Next j
For j = 15 To 31
Cells(i, j).Value = _
WorksheetFunction.VLookup(wsh.Name, SRb, j - 13, 0)
Next j
If Cells(i, j).Value >= 0 And Cells(i + 1, j).Value = "" Then
For j = 2 To 14
Cells(i + 1, j).Value = _
WorksheetFunction.VLookup(wsh.Name, SR, j, 0)
Next j
For j = 15 To 31
Cells(i + 1, j).Value = _
WorksheetFunction.VLookup(wsh.Name, SRb, j - 13, 0)
Next j
End If
Else:
For j = 2 To 14
Cells(dc, j).Value = _
WorksheetFunction.VLookup(wsh.Name, SR, j, 0)
Next j
For j = 15 To 31
Cells(i + 1, j).Value = _
WorksheetFunction.VLookup(wsh.Name, SRb, j - 13, 0)
Next j
End If
Application.ScreenUpdating = True
End Sub
nhân tiện nhờ các bác xem hộ em luôn đoạn code này còn có thể sai ở chỗ nào khác không.
em cảm ơn các bác nhiều !
