lequangtoan
Thành viên mới
- Tham gia
- 17/3/08
- Bài viết
- 1
- Được thích
- 0
Hiện tôi đang học phân tích tài chính bằng bảng excel. Trong Marco người ta viết như sau ( có file kèm theo), nhưng tôi thực sự hiểu quá ít về mã viết trong đó. Có đồng chí nào hiều về các dòng viết trong đó thì giải thích cho tôi với nhé (giải thích nôm na thôi, có nghĩa là dòng này để làm gì, dòng kia để làm gì..., chỉ ở mức như vậy thôi giúp tôi còn dễ hiểu). Xin cảm ơn!
Sub PTTC()
T = InputBox("So phuong an cong trinh", "Phan tich tai chinh", 1)
If T = "" Then
GoTo Line1: 'Ket thuc
End If
'Sheets("InF").Select
ColS = 13
pa = 1
For patc = 1 To T
Sheets("InE").Select
Range(Cells(9 + patc, 1), Cells(9 + patc, 15)).Select
Selection.Copy
Sheets("InE").Cells(8, 1).Select
Selection.PasteSpecial Paste:=xlValues
Sheets("InE").Cells(8, 1).Select
' ActiveSheet.Paste
Application.CutCopyMode = False
Sheets("InE").Cells(8, 1).Select
For s = 1 To Sheets("InF").Cells(1, 13).Value
Sheets("InF").Cells(2, 12).Value = Sheets("InF").Cells(2, ColS + s).Value 'Do nhay K
Sheets("InF").Cells(3, 12).Value = Sheets("InF").Cells(3, ColS + s).Value 'Do nhay E
Sheets("InF").Cells(1, 2).Value = Sheets("InF").Cells(1, ColS + s).Value 'Chu thich
For papvon = 1 To Sheets("InF").Cells(6, 12).Value
'Ty le nguon von
Sheets("InF").Cells(7, 7).Value = Sheets("InF").Cells(papvon + 6, 13) 'Von tu co
Sheets("InF").Cells(7, 8).Value = Sheets("InF").Cells(papvon + 6, 14) 'Von ngoai te
Sheets("InF").Cells(7, 9).Value = Sheets("InF").Cells(papvon + 6, 15) 'Von noi te
Sheets("InF").Cells(7, 10).Value = Sheets("InF").Cells(papvon + 6, 16) 'Von khac (EVN)
Sheets("InF").Cells(2, 10).Value = Sheets("InF").Cells(papvon + 6, 17) 'Von duoc ho tro (free)
Sheets("InF").Cells(1, 10).Value = Sheets("InF").Cells(papvon + 6, 18) 'Chu thich
'Thong so
Sheets("F1").Cells(2, 4).Value = Sheets("InF").Cells(1, 2) 'MND/MNC)
Sheets("F1").Cells(2, 8).Value = Sheets("InF").Cells(1, 10) 'Remark)
Sheets("F1").Cells(3, 3).Value = Sheets("InF").Cells(2, 2) 'Nlm)
Sheets("F1").Cells(4, 3).Value = Sheets("InF").Cells(2, 3) 'Ndb)
Sheets("F1").Cells(5, 3).Value = Sheets("InF").Cells(3, 2) 'Eo)
Sheets("F1").Cells(6, 3).Value = Sheets("InF").Cells(4, 2) 'Etm)
'Phan von
Sheets("F1").Cells(5, 7).Value = Sheets("InF").Cells(3, 5) 'Von thiet bi
For pvon = 1 To 7
Sheets("F1").Cells(pvon + 11, 16).Value = Sheets("InF").Cells(pvon + 7, 3) 'Von tu co
Sheets("F1").Cells(pvon + 11, 3).Value = Sheets("InF").Cells(pvon + 7, 4) 'Vay ngoai te
Sheets("F1").Cells(pvon + 11, 4).Value = Sheets("InF").Cells(pvon + 7, 5) 'Vay noi te
Sheets("F1").Cells(pvon + 11, 5).Value = Sheets("InF").Cells(pvon + 7, 6) 'Vay khac
Next pvon
'Gia ban
For Mucgia = 1 To Sheets("InF").Cells(18, 2).Value
Sheets("F1").Cells(7, 3).Value = Sheets("InF").Cells(18, Mucgia + 2) 'Gia ban)
'Lai vay
For Rnt = 1 To Sheets("InF").Cells(17, 2).Value
Sheets("F1").Cells(5, 15).Value = Sheets("InF").Cells(17, Rnt + 2) 'lai vay noi te
For Rngt = 1 To Sheets("InF").Cells(16, 2).Value
Sheets("F1").Cells(4, 15).Value = Sheets("InF").Cells(16, Rngt + 2) 'lai vay ngoai te
'Ket qua
Sheets("F1").Cells(2, 3).Value = pa 'Thu tu phuong an tinh toan
Sheets("KqF").Cells(4, pa + 2).Value = pa 'Thu tu phuong an tinh toan
Sheets("KqF").Cells(5, pa + 2).Value = Sheets("F1").Cells(2, 8).Value 'Remark
Sheets("KqF").Cells(7, pa + 2).Value = Sheets("F1").Cells(2, 4).Value 'MND/MNC
Sheets("KqF").Cells(8, pa + 2).Value = Sheets("F1").Cells(3, 3).Value 'Nlm
Sheets("KqF").Cells(9, pa + 2).Value = Sheets("F1").Cells(4, 3).Value 'Ndb
Sheets("KqF").Cells(10, pa + 2).Value = Sheets("F1").Cells(5, 3).Value 'Eo
Sheets("KqF").Cells(11, pa + 2).Value = Sheets("F1").Cells(6, 3).Value 'Etm
Sheets("KqF").Cells(14, pa + 2).Value = Sheets("F1").Cells(3, 7).Value 'VDT
Sheets("KqF").Cells(15, pa + 2).Value = Sheets("F1").Cells(3, 12).Value 'Von tu co
Sheets("KqF").Cells(16, pa + 2).Value = Sheets("F1").Cells(6, 12).Value 'Vay noi bo
Sheets("KqF").Cells(17, pa + 2).Value = Sheets("F1").Cells(4, 12).Value 'Vay ngoai te
Sheets("KqF").Cells(18, pa + 2).Value = Sheets("F1").Cells(5, 12).Value 'Vay noi te
Sheets("KqF").Cells(19, pa + 2).Value = Sheets("F1").Cells(6, 15).Value 'lai vay noi bo
Sheets("KqF").Cells(20, pa + 2).Value = Sheets("F1").Cells(4, 15).Value 'lai vay ngoai te
Sheets("KqF").Cells(21, pa + 2).Value = Sheets("F1").Cells(5, 15).Value 'lai vay noi te
Sheets("KqF").Cells(22, pa + 2).Value = Sheets("F1").Cells(4, 7).Value 'TMDT
Sheets("KqF").Cells(23, pa + 2).Value = Sheets("F1").Cells(7, 23).Value 'Chi phi cua CDT
Sheets("KqF").Cells(24, pa + 2).Value = Sheets("F1").Cells(8, 23).Value 'Von vay con lai
Sheets("KqF").Cells(26, pa + 2).Value = Sheets("F1").Cells(7, 3).Value 'Gia ban
Sheets("KqF").Cells(27, pa + 2).Value = Sheets("F1").Cells(3, 29).Value 'NPV
Sheets("KqF").Cells(28, pa + 2).Value = Sheets("F1").Cells(4, 29).Value 'ROE
Sheets("KqF").Cells(29, pa + 2).Value = Sheets("F1").Cells(5, 29).Value 'B/C
Sheets("KqF").Cells(30, pa + 2).Value = Sheets("F1").Cells(6, 29).Value 'Gia thanh
Sheets("KqF").Cells(31, pa + 2).Value = Sheets("F1").Cells(7, 29).Value 'Thv
Sheets("InF").Cells(2, 11).Value = pa
pa = pa + 1
Next Rngt
Next Rnt
Next Mucgia
Next papvon
Next s
Next patc
'********************************
'Format
Sheets("KqF").Select
Range(Cells(1, 3), Cells(260, 3)).Copy
Range(Cells(1, 3), Cells(260, pa + 2)).Select
Selection.PasteSpecial Paste:=xlFormats
Application.CutCopyMode = False
'Dat vung in & Ket thuc
Sheets("KqF").Activate
ActiveSheet.PageSetup.PrintArea = ""
'ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(26, pa + 2))
Cells(1, pa + 2).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.EntireColumn.Delete
Range("A1").Select
Line1:
End Sub
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 18/6/2003 by Doan Khanh Hoa
'
'
Range("B1515").Select
Selection.Copy
Range("B16").Select
ActiveSheet.Paste
End Sub
Public Function ThueTNDN(Mang, sn_mien, sn_giam, sn_uudai, MTUD, Thu_Nhap, nam) As Double
Dim i, dem As Integer
dem = 0
For i = 1 To nam
If Mang(i) > 0 Then
dem = dem + 1
End If
Next i
If dem <= sn_mien Then
ThueTNDN = 0
GoTo Thoat:
End If
If dem > sn_mien And dem <= (sn_mien + sn_giam) Then
ThueTNDN = MTUD / 2 * Thu_Nhap
GoTo Thoat:
End If
If dem > sn_giam And dem <= sn_uudai Then
ThueTNDN = MTUD * Thu_Nhap
GoTo Thoat:
End If
If dem > sn_uudai Then
ThueTNDN = 0.28 * Thu_Nhap
GoTo Thoat:
End If
Thoat:
End Function
Sub PTTC()
T = InputBox("So phuong an cong trinh", "Phan tich tai chinh", 1)
If T = "" Then
GoTo Line1: 'Ket thuc
End If
'Sheets("InF").Select
ColS = 13
pa = 1
For patc = 1 To T
Sheets("InE").Select
Range(Cells(9 + patc, 1), Cells(9 + patc, 15)).Select
Selection.Copy
Sheets("InE").Cells(8, 1).Select
Selection.PasteSpecial Paste:=xlValues
Sheets("InE").Cells(8, 1).Select
' ActiveSheet.Paste
Application.CutCopyMode = False
Sheets("InE").Cells(8, 1).Select
For s = 1 To Sheets("InF").Cells(1, 13).Value
Sheets("InF").Cells(2, 12).Value = Sheets("InF").Cells(2, ColS + s).Value 'Do nhay K
Sheets("InF").Cells(3, 12).Value = Sheets("InF").Cells(3, ColS + s).Value 'Do nhay E
Sheets("InF").Cells(1, 2).Value = Sheets("InF").Cells(1, ColS + s).Value 'Chu thich
For papvon = 1 To Sheets("InF").Cells(6, 12).Value
'Ty le nguon von
Sheets("InF").Cells(7, 7).Value = Sheets("InF").Cells(papvon + 6, 13) 'Von tu co
Sheets("InF").Cells(7, 8).Value = Sheets("InF").Cells(papvon + 6, 14) 'Von ngoai te
Sheets("InF").Cells(7, 9).Value = Sheets("InF").Cells(papvon + 6, 15) 'Von noi te
Sheets("InF").Cells(7, 10).Value = Sheets("InF").Cells(papvon + 6, 16) 'Von khac (EVN)
Sheets("InF").Cells(2, 10).Value = Sheets("InF").Cells(papvon + 6, 17) 'Von duoc ho tro (free)
Sheets("InF").Cells(1, 10).Value = Sheets("InF").Cells(papvon + 6, 18) 'Chu thich
'Thong so
Sheets("F1").Cells(2, 4).Value = Sheets("InF").Cells(1, 2) 'MND/MNC)
Sheets("F1").Cells(2, 8).Value = Sheets("InF").Cells(1, 10) 'Remark)
Sheets("F1").Cells(3, 3).Value = Sheets("InF").Cells(2, 2) 'Nlm)
Sheets("F1").Cells(4, 3).Value = Sheets("InF").Cells(2, 3) 'Ndb)
Sheets("F1").Cells(5, 3).Value = Sheets("InF").Cells(3, 2) 'Eo)
Sheets("F1").Cells(6, 3).Value = Sheets("InF").Cells(4, 2) 'Etm)
'Phan von
Sheets("F1").Cells(5, 7).Value = Sheets("InF").Cells(3, 5) 'Von thiet bi
For pvon = 1 To 7
Sheets("F1").Cells(pvon + 11, 16).Value = Sheets("InF").Cells(pvon + 7, 3) 'Von tu co
Sheets("F1").Cells(pvon + 11, 3).Value = Sheets("InF").Cells(pvon + 7, 4) 'Vay ngoai te
Sheets("F1").Cells(pvon + 11, 4).Value = Sheets("InF").Cells(pvon + 7, 5) 'Vay noi te
Sheets("F1").Cells(pvon + 11, 5).Value = Sheets("InF").Cells(pvon + 7, 6) 'Vay khac
Next pvon
'Gia ban
For Mucgia = 1 To Sheets("InF").Cells(18, 2).Value
Sheets("F1").Cells(7, 3).Value = Sheets("InF").Cells(18, Mucgia + 2) 'Gia ban)
'Lai vay
For Rnt = 1 To Sheets("InF").Cells(17, 2).Value
Sheets("F1").Cells(5, 15).Value = Sheets("InF").Cells(17, Rnt + 2) 'lai vay noi te
For Rngt = 1 To Sheets("InF").Cells(16, 2).Value
Sheets("F1").Cells(4, 15).Value = Sheets("InF").Cells(16, Rngt + 2) 'lai vay ngoai te
'Ket qua
Sheets("F1").Cells(2, 3).Value = pa 'Thu tu phuong an tinh toan
Sheets("KqF").Cells(4, pa + 2).Value = pa 'Thu tu phuong an tinh toan
Sheets("KqF").Cells(5, pa + 2).Value = Sheets("F1").Cells(2, 8).Value 'Remark
Sheets("KqF").Cells(7, pa + 2).Value = Sheets("F1").Cells(2, 4).Value 'MND/MNC
Sheets("KqF").Cells(8, pa + 2).Value = Sheets("F1").Cells(3, 3).Value 'Nlm
Sheets("KqF").Cells(9, pa + 2).Value = Sheets("F1").Cells(4, 3).Value 'Ndb
Sheets("KqF").Cells(10, pa + 2).Value = Sheets("F1").Cells(5, 3).Value 'Eo
Sheets("KqF").Cells(11, pa + 2).Value = Sheets("F1").Cells(6, 3).Value 'Etm
Sheets("KqF").Cells(14, pa + 2).Value = Sheets("F1").Cells(3, 7).Value 'VDT
Sheets("KqF").Cells(15, pa + 2).Value = Sheets("F1").Cells(3, 12).Value 'Von tu co
Sheets("KqF").Cells(16, pa + 2).Value = Sheets("F1").Cells(6, 12).Value 'Vay noi bo
Sheets("KqF").Cells(17, pa + 2).Value = Sheets("F1").Cells(4, 12).Value 'Vay ngoai te
Sheets("KqF").Cells(18, pa + 2).Value = Sheets("F1").Cells(5, 12).Value 'Vay noi te
Sheets("KqF").Cells(19, pa + 2).Value = Sheets("F1").Cells(6, 15).Value 'lai vay noi bo
Sheets("KqF").Cells(20, pa + 2).Value = Sheets("F1").Cells(4, 15).Value 'lai vay ngoai te
Sheets("KqF").Cells(21, pa + 2).Value = Sheets("F1").Cells(5, 15).Value 'lai vay noi te
Sheets("KqF").Cells(22, pa + 2).Value = Sheets("F1").Cells(4, 7).Value 'TMDT
Sheets("KqF").Cells(23, pa + 2).Value = Sheets("F1").Cells(7, 23).Value 'Chi phi cua CDT
Sheets("KqF").Cells(24, pa + 2).Value = Sheets("F1").Cells(8, 23).Value 'Von vay con lai
Sheets("KqF").Cells(26, pa + 2).Value = Sheets("F1").Cells(7, 3).Value 'Gia ban
Sheets("KqF").Cells(27, pa + 2).Value = Sheets("F1").Cells(3, 29).Value 'NPV
Sheets("KqF").Cells(28, pa + 2).Value = Sheets("F1").Cells(4, 29).Value 'ROE
Sheets("KqF").Cells(29, pa + 2).Value = Sheets("F1").Cells(5, 29).Value 'B/C
Sheets("KqF").Cells(30, pa + 2).Value = Sheets("F1").Cells(6, 29).Value 'Gia thanh
Sheets("KqF").Cells(31, pa + 2).Value = Sheets("F1").Cells(7, 29).Value 'Thv
Sheets("InF").Cells(2, 11).Value = pa
pa = pa + 1
Next Rngt
Next Rnt
Next Mucgia
Next papvon
Next s
Next patc
'********************************
'Format
Sheets("KqF").Select
Range(Cells(1, 3), Cells(260, 3)).Copy
Range(Cells(1, 3), Cells(260, pa + 2)).Select
Selection.PasteSpecial Paste:=xlFormats
Application.CutCopyMode = False
'Dat vung in & Ket thuc
Sheets("KqF").Activate
ActiveSheet.PageSetup.PrintArea = ""
'ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(26, pa + 2))
Cells(1, pa + 2).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.EntireColumn.Delete
Range("A1").Select
Line1:
End Sub
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 18/6/2003 by Doan Khanh Hoa
'
'
Range("B1515").Select
Selection.Copy
Range("B16").Select
ActiveSheet.Paste
End Sub
Public Function ThueTNDN(Mang, sn_mien, sn_giam, sn_uudai, MTUD, Thu_Nhap, nam) As Double
Dim i, dem As Integer
dem = 0
For i = 1 To nam
If Mang(i) > 0 Then
dem = dem + 1
End If
Next i
If dem <= sn_mien Then
ThueTNDN = 0
GoTo Thoat:
End If
If dem > sn_mien And dem <= (sn_mien + sn_giam) Then
ThueTNDN = MTUD / 2 * Thu_Nhap
GoTo Thoat:
End If
If dem > sn_giam And dem <= sn_uudai Then
ThueTNDN = MTUD * Thu_Nhap
GoTo Thoat:
End If
If dem > sn_uudai Then
ThueTNDN = 0.28 * Thu_Nhap
GoTo Thoat:
End If
Thoat:
End Function