Mình có sưu tầm đoạn code kết chuyển số dư sang một file excel khác.
Ví dụ : Ta có một file excel kế toán tiền mặt kết chuyển sang tháng sau.
Ta có đoạn code như sau :
Sub button1_click()
Dim tenfile As String
Dim ten As Integer
Dim tl
tl = MsgBox("Ban thuc su muon ket chuyen ! ", vbOKCancel, "Thong bao")
If tl = vbOK Then
ActiveWindow.SmallScroll down:=22
Range("C35").Select
Selection.Copy
ActiveWindow.SmallScroll down:=22
Range("C4").Select
Selection.PasteSpecial Paste:=xlValues, operation:=xlNone, skipblanks:=False, Transpose:=False
Range("D2").Select
Application.CutCopyMode = False
Selection.Copy
Range("C2").Select
Selection.PasteSpecial Paste:=xlValues, operation:=xlNone, skipblanks:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("THU").Select
Range("A6:E250").Select
Selection.ClearContents
Range("A6").Select
Sheets("CHI").Select
Range("A6:E250").Select
Selection.ClearContents
Range("A6").Select
Sheets("TONGKETQUY").Select
ten = Application.Range("C2").Value
tenfile = "CMy Documents\KTTM thang " & ten & ".xls"
ActiveWorkbook.SaveAs Filename:=tenfile, FileFormat:=xlNormal, Password:="", writerespassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
End If
End sud
Ví dụ : Ta có một file excel kế toán tiền mặt kết chuyển sang tháng sau.
Ta có đoạn code như sau :
Sub button1_click()
Dim tenfile As String
Dim ten As Integer
Dim tl
tl = MsgBox("Ban thuc su muon ket chuyen ! ", vbOKCancel, "Thong bao")
If tl = vbOK Then
ActiveWindow.SmallScroll down:=22
Range("C35").Select
Selection.Copy
ActiveWindow.SmallScroll down:=22
Range("C4").Select
Selection.PasteSpecial Paste:=xlValues, operation:=xlNone, skipblanks:=False, Transpose:=False
Range("D2").Select
Application.CutCopyMode = False
Selection.Copy
Range("C2").Select
Selection.PasteSpecial Paste:=xlValues, operation:=xlNone, skipblanks:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("THU").Select
Range("A6:E250").Select
Selection.ClearContents
Range("A6").Select
Sheets("CHI").Select
Range("A6:E250").Select
Selection.ClearContents
Range("A6").Select
Sheets("TONGKETQUY").Select
ten = Application.Range("C2").Value
tenfile = "CMy Documents\KTTM thang " & ten & ".xls"
ActiveWorkbook.SaveAs Filename:=tenfile, FileFormat:=xlNormal, Password:="", writerespassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
End If
End sud