lasxd15492018
Thành viên chính thức


- Tham gia
- 4/3/18
- Bài viết
- 72
- Được thích
- 7
- Giới tính
- Nam
Em có code copy sheet . Mỗi lần copy sẽ đặt tên giống như sheet(data) cột D như này ạ. Bây giờ em muốn bẫy lỗi khi tên trùng nhau thì sẽ hiện thông báo lỗi trùng tên ở đâu thì làm thế nào ạ.. em hỏi thêm sao module1 của em tự nhiên lại không mở được.
Sub Macro11()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim I As Variant
I = Cells(5, 2)
For I = Range("d1") To Cells(5, 2) 'InputBox("NHAP SO DONG ")
Cells(I, 4) = I
Sheets(Array("R7", "r28")).Select
Sheets("r28").Activate
Sheets(Array("R7", "r28")).Copy Before:=Sheets(1)
Sheets("r7 (2)").Select
Application.Run "'copy BT.xls'!Macro3"
Sheets("r7 (2)").Range("H16:J16").Formula = Sheet1.Cells((I + 1), 5)
Sheets("r7 (2)").Range("D13").Formula = Sheet1.Cells((I + 1), 6)
Sheets("r7 (2)").Range("D17").Formula = Sheet1.Cells((I + 1), 7)
Sheets("r28 (2)").Select
Application.Run "'copy BT.xls'!Macro3"
Sheets("R7 (2)").Name = Sheet1.Cells((I + 1), 4) & " r7"
Sheets("R28 (2)").Name = Sheet1.Cells((I + 1), 4) & " r28"
Next I
Exit Sub
End Sub
Sub Macro11()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim I As Variant
I = Cells(5, 2)
For I = Range("d1") To Cells(5, 2) 'InputBox("NHAP SO DONG ")
Cells(I, 4) = I
Sheets(Array("R7", "r28")).Select
Sheets("r28").Activate
Sheets(Array("R7", "r28")).Copy Before:=Sheets(1)
Sheets("r7 (2)").Select
Application.Run "'copy BT.xls'!Macro3"
Sheets("r7 (2)").Range("H16:J16").Formula = Sheet1.Cells((I + 1), 5)
Sheets("r7 (2)").Range("D13").Formula = Sheet1.Cells((I + 1), 6)
Sheets("r7 (2)").Range("D17").Formula = Sheet1.Cells((I + 1), 7)
Sheets("r28 (2)").Select
Application.Run "'copy BT.xls'!Macro3"
Sheets("R7 (2)").Name = Sheet1.Cells((I + 1), 4) & " r7"
Sheets("R28 (2)").Name = Sheet1.Cells((I + 1), 4) & " r28"
Next I
Exit Sub
End Sub