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


- Tham gia
- 2/6/10
- Bài viết
- 87
- Được thích
- 41
- Nghề nghiệp
- IT
Sub filldulieu()
Application.ScreenUpdating = False
Dim wb As Workbook
Dim ws As Worksheet
Set wb = Workbooks("HANGHOA.xlsm")
Set ws = wb.Sheets("NHAP")
ws.Range("rangefillnhap1Copy").Copy
With ws.Range("rangefillnhap1paste")
.PasteSpecial xlPasteFormulas
.Value = ws.Range("rangefillnhap1paste").Value
End With
ws.Range("rangefillnhap2Copy").Copy
With ws.Range("rangefillnhap2paste")
.PasteSpecial xlPasteFormulas
.Value = ws.Range("rangefillnhap2paste").Value
End With
Set ws = wb.Sheets("KHOCHINHXUAT")
ws.Range("rangefillKhochinhxuat1Copy").Copy
With ws.Range("rangefillKhochinhxuat1paste")
.PasteSpecial xlPasteFormulas
.Value = ws.Range("rangefillKhochinhxuat1paste").Value
End With
ws.Range("rangefillKhochinhxuat2Copy").Copy
With ws.Range("rangefillKhochinhxuat2paste")
.PasteSpecial xlPasteFormulas
.Value = ws.Range("rangefillKhochinhxuat2paste").Value
End With
Set ws = wb.Sheets("TONCUOI")
ws.Range("rangefillToncuoiCopy").Copy
With ws.Range("rangefillToncuoiPaste")
.PasteSpecial xlPasteFormulas
.Value = ws.Range("rangefillToncuoiPaste").Value
End With
Set ws = wb.Sheets("XUATLUUCHUYEN")
ws.Range("rangefillXuatluuchuyenCopy").Copy
With ws.Range("rangefillXuatluuchuyenPaste")
.PasteSpecial xlPasteValues
End With
Set ws = wb.Sheets("XUATBUFFET")
ws.Range("rangefillXuatbuffetCopy").Copy
With ws.Range("rangefillXuatbuffetPaste")
.PasteSpecial xlPasteValues
End With
Set ws = wb.Sheets("XUATK")
ws.Range("rangefillXuatkCopy").Copy
With ws.Range("rangefillXuatkPaste")
.PasteSpecial xlPasteValues
End With
'Application.ScreenUpdating = True: Exit Sub
End Sub
Tóm lại: Copy dữ liệu rồi paste,
Nhưng vấn đề là: mỗi sheet copy và paste vào những vùng khác nhau. (đã cố định vị trí).
Câu hỏi là: Viết lại code như thế nào cho đơn giản.
Em xin cảm ơn !
(ghi chú: code trên đang hoạt động tốt).
Application.ScreenUpdating = False
Dim wb As Workbook
Dim ws As Worksheet
Set wb = Workbooks("HANGHOA.xlsm")
Set ws = wb.Sheets("NHAP")
ws.Range("rangefillnhap1Copy").Copy
With ws.Range("rangefillnhap1paste")
.PasteSpecial xlPasteFormulas
.Value = ws.Range("rangefillnhap1paste").Value
End With
ws.Range("rangefillnhap2Copy").Copy
With ws.Range("rangefillnhap2paste")
.PasteSpecial xlPasteFormulas
.Value = ws.Range("rangefillnhap2paste").Value
End With
Set ws = wb.Sheets("KHOCHINHXUAT")
ws.Range("rangefillKhochinhxuat1Copy").Copy
With ws.Range("rangefillKhochinhxuat1paste")
.PasteSpecial xlPasteFormulas
.Value = ws.Range("rangefillKhochinhxuat1paste").Value
End With
ws.Range("rangefillKhochinhxuat2Copy").Copy
With ws.Range("rangefillKhochinhxuat2paste")
.PasteSpecial xlPasteFormulas
.Value = ws.Range("rangefillKhochinhxuat2paste").Value
End With
Set ws = wb.Sheets("TONCUOI")
ws.Range("rangefillToncuoiCopy").Copy
With ws.Range("rangefillToncuoiPaste")
.PasteSpecial xlPasteFormulas
.Value = ws.Range("rangefillToncuoiPaste").Value
End With
Set ws = wb.Sheets("XUATLUUCHUYEN")
ws.Range("rangefillXuatluuchuyenCopy").Copy
With ws.Range("rangefillXuatluuchuyenPaste")
.PasteSpecial xlPasteValues
End With
Set ws = wb.Sheets("XUATBUFFET")
ws.Range("rangefillXuatbuffetCopy").Copy
With ws.Range("rangefillXuatbuffetPaste")
.PasteSpecial xlPasteValues
End With
Set ws = wb.Sheets("XUATK")
ws.Range("rangefillXuatkCopy").Copy
With ws.Range("rangefillXuatkPaste")
.PasteSpecial xlPasteValues
End With
'Application.ScreenUpdating = True: Exit Sub
End Sub
Tóm lại: Copy dữ liệu rồi paste,
Nhưng vấn đề là: mỗi sheet copy và paste vào những vùng khác nhau. (đã cố định vị trí).
Câu hỏi là: Viết lại code như thế nào cho đơn giản.
Em xin cảm ơn !
(ghi chú: code trên đang hoạt động tốt).
Lần chỉnh sửa cuối: