0% found this document useful (0 votes)
5 views

code

The document contains VBA code for a user interface with buttons to handle data entry and display messages. It includes functionality to format input values, manage data in Excel sheets, and validate inputs before processing. The code also provides feedback to the user upon successful data saving and handles potential errors during the process.

Uploaded by

Nguyễn Châu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

code

The document contains VBA code for a user interface with buttons to handle data entry and display messages. It includes functionality to format input values, manage data in Excel sheets, and validate inputs before processing. The code also provides feedback to the user upon successful data saving and handles potential errors during the process.

Uploaded by

Nguyễn Châu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Private Sub CommandButton1_Click()

MsgBox "Du lieu se duoc dong", 0, "message"

Unload Du_lieu

End Sub

Private Sub CommandButton2_Click()

Unload Du_lieu

End Sub

Private Sub Txt_Gia_Change()

Txt_Gia = Format(Txt_Gia, "#,##0")

End Sub

Dim Cuoi As Integer

Cuoi = Sheets("DU LIEU MA VAT TU").Range("k1").Value + 1

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 0).Value = "PN" & Txt_PN

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 22).Value = Txt_Ma

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 23).Value = Txt_Mau

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 1).Value = Txt_Ma & Txt_Mau

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 2).Value = Txt_Ten

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 3).Value = "AC" & Txt_Mau

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 4).Value = Txt_DV

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 5).Value = Txt_Dai

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 6).Value = Txt_SL

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 7).Value = Txt_SLtinhtien

Sheets("Nhap").Range("batdaunhap").Offset(Cuoi, 8).Value = Txt_Thanhtien

cuoi_khoxuat = khoxuat.Range("F" & Rows.Count).End(xlUp).Row

cuoi_phieuxuat = phieuxuat.Range("D" & Rows.Count).End(xlUp).Row

If phieuxuat.Range("n7").Value = "" Then

MsgBox "Thieu ngay nhap kho"

Exit Sub

ElseIf cuoi_phieuxuat <= 16 Then


MsgBox "Khong co ma hang"

Exit Sub

Else

Dim i As Long

For i = 17 To cuoi_phieuxuat

If phieuxuat.Range("D" & i).Value <> "" Then

khoxuat.Range("E" & cuoi_khoxuat + 1 & ":P" & cuoi_khoxuat + 1).Value = phieuxuat.Range("C" & i &
":n" & i).Value

khoxuat.Range("B" & cuoi_khoxuat + 1).Value = phieuxuat.Range("N7").Value

khoxuat.Range("C" & cuoi_khoxuat + 1).Value = phieuxuat.Range("N8").Value

khoxuat.Range("D" & cuoi_khoxuat + 1).Value = phieuxuat.Range("G13").Value

cuoi_khoxuat = cuoi_khoxuat + 1

End If

Next i

khoxuat.Range("q" & cuoi_khoxuat).Value = phieuxuat.Range("N36").Value

khoxuat.Range("R" & cuoi_khoxuat).Value = phieuxuat.Range("N37").Value

khoxuat.Range("S" & cuoi_khoxuat).Value = phieuxuat.Range("N38").Value

MsgBox "Luu thanh cong"

End If

End Sub

You might also like