Bạn sửa code nút in nhãn thế này xem sao.Em muốn thiết lập code in nhãn tự động. Loay hoay mãi không nghĩ ra giải pháp nên em đưa lên đây nhờ các cao thủ chỉ dùm em.
Câu hỏi cụ thể trong file đính kèm.
Cám ơn!
Private Sub CommandButton2_Click()
Dim so As Integer, i As Integer, s As String, ss As String
s = Format(S1.Range("I1"), "yyyymmdd") & Format(S1.Range("I2"), "0000")
ss = Format(ActiveCell.Offset(, 4).Value, "000")
With S2
.Range("A9", .Range("A65000").End(xlUp).Offset(1)).Resize(, 2).Clear
so = ActiveCell.Offset(, 4).Value
For i = 1 To so
If i <> 1 Then .Range("A2:B7").Copy .Range("A" & (1 + (i - 1) * 8))
.Range("B" & (IIf(i = 1, 2, 1) + (i - 1) * 8)).Offset(4).Value = s & "-" & Format(i, "000") & ss
Next i
.PrintOut Copies:=1, Collate:=True
End With
Unload Me
End Sub
Thử code này nhé bạn.Em đã áp dụng vào file của em thì được rồi ạ. Em muốn hỏi anh thêm 1 vấn đề nữa:
Em muốn khi in nhãn nó cũng cập nhật được thêm Mã hàng và Tên hàng đã chọn in vào nhãn nữa.
Cám ơn anh nhiều!
Private Sub CommandButton2_Click()
Dim so As Integer, i As Integer, s As String, ss As String, k1 As String, k2 As String
s = Format(S7.Range("M5"), "yyyymmdd") & Format(S7.Range("M6"), "0000")
ss = Format(ActiveCell.Offset(, 5).Value, "000")
k1 = S7.Range("B" & ActiveCell.Row).Value
k2 = ActiveCell.Value
so = ActiveCell.Offset(, 5).Value
S14.Select
With S14
For i = 1 To so
.Range("B6").Value = s & "-" & Format(i, "000") & "/" & ss
.Range("B3").Value = k2
.Range("B4").Value = k1
.PrintOut Copies:=1, Collate:=True
Next i
End With
Unload Me
End Sub
DIỄN ĐÀN GIẢI PHÁP EXCEL Group 1
DIỄN ĐÀN GIẢI PHÁP EXCEL Group 2