Nhờ các anh chị giải thích đoạn code về nhập dữ liệu sang excel giúp em với (1 người xem)

Liên hệ QC

Người dùng đang xem chủ đề này

tamnguoiban

Thành viên mới
Tham gia
14/5/09
Bài viết
4
Được thích
0
em chưa hiểu lắm về đoạn code này. Nhờ các anh chị trong diễn đàn giải thích giúp em với.
Mong các anh chị chỉ giáo.Em cảm ơn nhiều

Private Sub NutGhi_Click()
Dim i As Long
'i = S1.Range("A650000").End(xlUp).Row
i = S1.Cells(Cells.Rows.Count, 1).End(3).Row
With S1
.Cells(i + 1, 1).Value = Me.XSogiay.Value
.Cells(i + 1, 2).Value = Me.XQuyenso.Value
.Cells(i + 1, 3).Value = Me.XHovaten.Text
.Cells(i + 1, 4).Value = Me.XGioitinh.Value
.Cells(i + 1, 5).Value = CDate(Me.XNgaysinh.Value)
.Cells(i + 1, 6).Value = Me.XGhibangchu.Text
.Cells(i + 1, 7).Value = Me.XNoisinh.Text
.Cells(i + 1, 8).Value = Me.XDantoc.Text
.Cells(i + 1, 9).Value = Me.XQuoctich.Text
.Cells(i + 1, 10).Value = Me.XHovatencha.Text
.Cells(i + 1, 11).Value = Me.XNamsinhcha.Value
.Cells(i + 1, 12).Value = Me.XDantoccha.Value
.Cells(i + 1, 13).Value = Me.XQuoctichcha.Value
.Cells(i + 1, 14).Value = Me.XThuongtrucha.Text
.Cells(i + 1, 15).Value = Me.XHovatenme.Text
.Cells(i + 1, 16).Value = Me.XNamsinhme.Value
.Cells(i + 1, 17).Value = Me.XDantocme.Value
.Cells(i + 1, 18).Value = Me.XQuoctichme.Value
.Cells(i + 1, 19).Value = Me.XThuongtrume.Text
.Cells(i + 1, 20).Value = Me.XNoidangky.Value
.Cells(i + 1, 21).Value = CDate(Me.XNgaydangky.Value)
.Cells(i + 1, 22).Value = Me.XGhichu.Text
.Cells(i + 1, 23).Value = Me.Xhovatennguoidikhai.Text
.Cells(i + 1, 24).Value = Me.XQuanhe.Text
.Cells(i + 1, 25).Value = Me.XHovatennguoithuchien.Text
.Cells(i + 1, 26).Value = Me.XHovatennguoiky.Text
.Cells(i + 1, 27).Value = Me.XChucvu.Text
Me.XSogiay.Value = ""
Me.XQuyenso.Value = ""
Me.XHovaten.Text = ""
Me.XGioitinh.Value = ""
Me.XNgaysinh.Value = ""
Me.XGhibangchu.Value = ""
Me.XNoisinh.Text = ""
Me.XDantoc.Text = ""
Me.XQuoctich.Text = ""
Me.XHovatencha.Text = ""
Me.XNamsinhcha.Text = ""
Me.XDantoccha.Value = ""
Me.XQuoctichcha.Value = ""
Me.XThuongtrucha.Text = ""
Me.XHovatenme.Text = ""
Me.XNamsinhme.Text = ""
Me.XDantocme.Value = ""
Me.XQuoctichme.Value = ""
Me.XThuongtrume.Text = ""
Me.XNoidangky.Value = ""
Me.XNgaydangky.Value = ""
Me.XGhichu.Text = ""
Me.Xhovatennguoidikhai.Text = ""
Me.XQuanhe.Text = ""
Me.XHovatennguoithuchien.Text = ""
Me.XHovatennguoiky.Text = ""
Me.XChucvu.Text = ""
Me.XSogiay.SetFocus
End With
End Sub
 
Nhờ anh chị trong diễn đàn giải thích giúp em với.
PHP:
Private Sub NutGhi_Click()
1 Dim i As Long   'Khai Báo 1 Biến i Kiểu Long'
 'i = S1.Range("A650000").End(xlUp).Row'
3 i = S1.Cells(Cells.Rows.Count, 1).End(3).Row  
 'Lấy Dòng Cuối Có Dữ Liệu Gán Vô i'
 With S1    '.. .  Đến Dòng 12: Thông báo làm Việc Với S1'
' Các Dòng Lệnh Từ 5. . .  Trước 7: Gán Trị Từ Form Vô Trang Tính' 
5   .Cells(i + 1, 1).Value = Me.XSogiay.Value
   .Cells(i + 1, 2).Value = Me.XQuyenso.Value
   .Cells(i + 1, 3).Value = Me.XHovaten.Text
   .Cells(i + 1, 4).Value = Me.XGioitinh.Value
   .Cells(i + 1, 5).Value = CDate(Me.XNgaysinh.Value)
   .Cells(i + 1, 6).Value = Me.XGhibangchu.Text
   .Cells(i + 1, 7).Value = Me.XNoisinh.Text
   .Cells(i + 1, 8).Value = Me.XDantoc.Text
   .Cells(i + 1, 9).Value = Me.XQuoctich.Text
   .Cells(i + 1, 10).Value = Me.XHovatencha.Text
   .Cells(i + 1, 11).Value = Me.XNamsinhcha.Value
   .Cells(i + 1, 12).Value = Me.XDantoccha.Value
7   '. . . . . . . '
 'Các Dòng Lệnh Tương Tự Như 8: Xóa Dữ Liệu Các Control Trong Form' 
    Me.XQuoctichcha.Value = ""
9    Me.XThuongtrucha.Text = ""
    Me.XHovatenme.Text = ""
    Me.XNamsinhme.Text = ""
    Me.XDantocme.Value = ""
    Me.XQuoctichme.Value = ""
    Me.XThuongtrume.Text = ""
    Me.XNoidangky.Value = ""
    Me.XNgaydangky.Value = ""
    Me.XGhichu.Text = ""
    Me.Xhovatennguoidikhai.Text = ""
    Me.XQuanhe.Text = ""
    Me.XHovatennguoithuchien.Text = ""
    Me.XHovatennguoiky.Text = ""
    Me.XChucvu.Text = ""
11    Me.XSogiay.SetFocus
 End With
End Sub
--=0 --=0 --=0 --=0 --=0 --=0 --=0 --=0
 
Upvote 0

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

Back
Top Bottom