Viết code VBA cho file báo cáo

Liên hệ QC

kimthoa89

Thành viên thường trực
Tham gia
3/11/17
Bài viết
219
Được thích
17
Giới tính
Nữ
Dear anh chị !
Nhờ anh chị viết code giúp e cho file báo cáo
1. Toàn bộ dữ liệu được nhập ở phần Nhập được ghi lại xuống phần Data
2. Những model được bỏ trống thì không được thêm vào phần Data
Em cảm ơn anh chị !
222292
 

File đính kèm

Dear anh chị !
Nhờ anh chị viết code giúp e cho file báo cáo
1. Toàn bộ dữ liệu được nhập ở phần Nhập được ghi lại xuống phần Data
2. Những model được bỏ trống thì không được thêm vào phần Data
Em cảm ơn anh chị !
View attachment 222292
Bạn xem file được chưa?

Mã:
Sub nhap_lieu()
Dim i As Long, Lr As Long

With Sheet1
    For i = 3 To 13
        Lr = .Range("F50000").End(xlUp).Row + 1
        If .Cells(4, i).Value <> "" Then
            .Range("F" & Lr).Value = .Cells(4, i)
            .Range("C" & Lr).Value = .Range("C2")
            .Range("B" & Lr).Value = Month(.Range("C2"))
            .Range("D" & Lr).Value = .Cells(7, i)
            .Range("E" & Lr).Value = .Cells(8, i)
            If .Range("G10").Value = .Cells(5, i).Value Then
                .Range("G" & Lr).Value = .Cells(4, i).Offset(2)
            End If
            If .Range("H10").Value = .Cells(5, i).Value Then
                .Range("H" & Lr).Value = .Cells(4, i).Offset(2)
            End If
            If .Range("I10").Value = .Cells(5, i).Value Then
                .Range("I" & Lr).Value = .Cells(4, i).Offset(2)
            End If
            If .Range("J10").Value = .Cells(5, i).Value Then
                .Range("J" & Lr).Value = .Cells(4, i).Offset(2)
            End If
            If .Range("K10").Value = .Cells(5, i).Value Then
                .Range("K" & Lr).Value = .Cells(4, i).Offset(2)
            End If
            If .Range("L10").Value = .Cells(5, i).Value Then
                .Range("L" & Lr).Value = .Cells(4, i).Offset(2)
            End If
            If .Range("M10").Value = .Cells(5, i).Value Then
                .Range("M" & Lr).Value = .Cells(4, i).Offset(2)
            End If
            If .Range("N10").Value = .Cells(5, i).Value Then
                .Range("N" & Lr).Value = .Cells(4, i).Offset(2)
            End If
            If .Range("O10").Value = .Cells(5, i).Value Then
                .Range("O" & Lr).Value = .Cells(4, i).Offset(2)
            End If
            If .Range("p10").Value = .Cells(5, i).Value Then
                .Range("p" & Lr).Value = .Cells(4, i).Offset(2)
            End If
            If .Range("q10").Value = .Cells(5, i).Value Then
                .Range("q" & Lr).Value = .Cells(4, i).Offset(2)
            End If

        End If
    Next i
End With

End Sub
 

File đính kèm

Upvote 0
Web KT

Bài viết mới nhất

Back
Top Bottom