Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.55 KB | None | 0 0
  1. ' ¡Ò˹´Ê¶Ò¹Ð¢Í§ TextBox ÇèÒãËéãªé§Ò¹ä´éËÃ×ÍäÁè
  2. Sub textStatus(textName, textOwner, textCost, textPeriod, textCostOfCapital, textCashFlow)
  3. If textName Then InvestmentForm.txtName.Enabled = True _
  4. Else InvestmentForm.txtName.Enabled = False
  5. If textOwner Then InvestmentForm.txtOwner.Enabled = True _
  6. Else InvestmentForm.txtOwner.Enabled = False
  7. If textCost Then InvestmentForm.txtCost.Enabled = True _
  8. Else InvestmentForm.txtCost.Enabled = False
  9. If textPeriod Then InvestmentForm.txtPeriod.Enabled = True _
  10. Else InvestmentForm.txtPeriod.Enabled = False
  11. If textCostOfCapital Then InvestmentForm.txtCostOfCapital.Enabled = True _
  12. Else InvestmentForm.txtCostOfCapital.Enabled = False
  13.  
  14. If textCashFlow Then InvestmentForm.txtCashFlow.Enabled = True _
  15. Else InvestmentForm.txtCashFlow.Enabled = False
  16. End Sub
  17. ' ¡Ò˹´ÊÕ¾×é¹ËÅѧ¢Í§ TextBox
  18. Sub textBGStatus(textName, textOwner, textCost, textPeriod, textCostOfCapital, textCashFlow)
  19. If textName Then InvestmentForm.txtName.BackColor = &H80000005 _
  20. Else InvestmentForm.txtName.BackColor = &H80000018
  21. If textOwner Then InvestmentForm.txtOwner.BackColor = &H80000005 _
  22. Else InvestmentForm.txtOwner.BackColor = &H80000018
  23. If textCost Then InvestmentForm.txtCost.BackColor = &H80000005 _
  24. Else InvestmentForm.txtCost.BackColor = &H80000018
  25. If textPeriod Then InvestmentForm.txtPeriod.BackColor = &H80000005 _
  26. Else InvestmentForm.txtPeriod.BackColor = &H80000018
  27. If textCostOfCapital Then InvestmentForm.txtCostOfCapital.BackColor = &H80000005 _
  28. Else InvestmentForm.txtCostOfCapital.BackColor = &H80000018
  29. If textCashFlow Then InvestmentForm.txtCashFlow.BackColor = &H80000005 _
  30. Else InvestmentForm.txtCashFlow.BackColor = &H80000018
  31. End Sub
  32. ' à¤ÅÕÂÃì¢éͤÇÒÁÀÒÂã¹ TextBox
  33. Sub textValue(textName, textOwner, textCost, textPeriod, textCostOfCapital, textCashFlow)
  34. If textName Then InvestmentForm.txtName.Value = Clear
  35. If textOwner Then InvestmentForm.txtOwner.Value = Clear
  36. If textCost Then InvestmentForm.txtCost.Value = Clear
  37. If textPeriod Then InvestmentForm.txtPeriod.Value = Clear
  38. If textCostOfCapital Then InvestmentForm.txtCostOfCapital.Value = Clear
  39. If textCashFlow Then InvestmentForm.txtCashFlow.Value = Clear
  40. End Sub
  41. ' ¡Ò˹´Ê¶Ò¹Ð¢Í§»ØèÁÇèÒãËéãªé§Ò¹ä´éËÃ×ÍäÁè
  42. Sub buttonStatus(saveButton, nextButton, previousButton, addNewButton, editButton, analyzeButton, exitButton)
  43. If saveButton Then InvestmentForm.cmdSaveProject.Locked = False _
  44. Else InvestmentForm.cmdSaveProject.Locked = True
  45. If nextButton Then InvestmentForm.cmdNextYear.Locked = False _
  46. Else InvestmentForm.cmdNextYear.Locked = True
  47. If previousButton Then InvestmentForm.cmdPreviousYear.Locked = False _
  48. Else InvestmentForm.cmdPreviousYear.Locked = True
  49. If addNewButton Then InvestmentForm.cmdAddNewProject.Locked = False _
  50. Else InvestmentForm.cmdAddNewProject.Locked = True
  51. If editButton Then InvestmentForm.cmdEditData.Locked = False _
  52. Else InvestmentForm.cmdEditData.Locked = True
  53. If analyzeButton Then InvestmentForm.cmdAnalyzeAll.Locked = False _
  54. Else InvestmentForm.cmdAnalyzeAll.Locked = True
  55. If exitButton Then InvestmentForm.cmdExit.Locked = False _
  56. Else InvestmentForm.cmdExit.Locked = True
  57. End Sub
  58. ' ¡Ò˹´Ê¶Ò¹Ð¢éͤÇÒÁ·Õèà»ç¹¤Ò͸ԺÒ»ØèÁµèÒ§ æ
  59. Sub labelButtonStatus(saveLabel, nextLabel, previousLabel, addNewLabel, editLAbel, analyzeLabel, exitLabel)
  60. If saveLabel Then InvestmentForm.lblSaveProject.Enabled = True _
  61. Else InvestmentForm.lblSaveProject.Enabled = False
  62. If nextLabel Then InvestmentForm.lblNext.Enabled = True _
  63. Else InvestmentForm.lblNext.Enabled = False
  64. If previousLabel Then InvestmentForm.lblPrevious.Enabled = True _
  65. Else InvestmentForm.lblPrevious.Enabled = False
  66. If addNewLabel Then InvestmentForm.lblCreateProject.Enabled = True _
  67. Else InvestmentForm.lblCreateProject.Enabled = False
  68. If editLAbel Then InvestmentForm.lblEdit.Enabled = True _
  69. Else InvestmentForm.lblEdit.Enabled = False
  70. If analyzeLabel Then InvestmentForm.lblAnalyze.Enabled = True _
  71. Else InvestmentForm.lblAnalyze.Enabled = False
  72. If exitLabel Then InvestmentForm.lblExit.Enabled = True _
  73. Else InvestmentForm.lblExit.Enabled = False
  74. End Sub
  75. Sub checkNameString(KeyAscii)
  76. If KeyAscii = 42 Or KeyAscii = 47 Or KeyAscii = 58 Or KeyAscii = 63 Or KeyAscii = 91 Or KeyAscii = 92 Or KeyAscii = 93 Then KeyAscii = 0
  77. End Sub
  78. Sub checkNumeric(KeyAscii, Optional cash)
  79. If KeyAscii < 48 Or KeyAscii > 57 Then
  80. If cash = "No" Then
  81. KeyAscii = 0
  82. Else
  83. If KeyAscii = 45 Then KeyAscii = 45 Else KeyAscii = 0
  84. End If
  85. End If
  86. End Sub
  87. Function numericFormat(dataValue)
  88. On Error Resume Next
  89. numericFormat = FormatNumber(dataValue, 2, , , vbTrue)
  90. If Err.Number = "13" Then Call errorMessage("¢éÍÁÙżԴ¾ÅÒ´", "vbCritical", "¼Ô´¾ÅÒ´")
  91. End Function
  92. Function errorMessage(errData, vbIcon, msgTitle)
  93. result = MsgBox(errData, vbIcon, msgTitle)
  94. errorMessage = result
  95. End Function
  96. Function createProject(proName, proOwner, proCost, proPeriod, proCostOfCapital, OptionalworkingStatus)
  97. Dim newSheet As Worksheet
  98. For Each newSheet In Worksheets
  99. If newSheet.Name = proName Or proName = "ProjAnalysis" Then
  100. If ActiveSheet.Name = proName And workingStatus = "edit" Then Exit For
  101. Call errorMessage("?????????????????????????????", vbCritical, "???????")
  102. InvestmentForm.txtName.SetFocus
  103. projectName = "No"
  104. editProjectName = "No"
  105. Call buttonStatus(1, 0, 0, 0, 0, 0, 1)
  106. Call labelButtonStatus(1, 0, 0, 0, 0, 0, 1)
  107. Exit For
  108. Else
  109. projectName = "Yes"
  110. End If
  111. Next newSheet
  112. If workingStatus = "edit" And editProjectName <> "No" Then
  113. projectName = "Edit"
  114. ActiveSheet.Name = proName
  115. Call addDataToSheet(proName, proOwner, proCost, proPeriod, proCostOfCapital)
  116. Call textStatus(0, 0, 0, 0, 0, 1)
  117. Call textBGStatus(0, 0, 0, 0, 0, 1)
  118. Call buttonStatus(0, 1, 0, 0, 1, 0, 1)
  119. Call labelButtonStatus(0, 1, 0, 0, 1, 0, 1)
  120. InvestmentForm.txtCashFlow.SetFocus
  121. End If
  122. If workingStatus <> "edit" And projectName = "Yes" Then
  123. Application.Worksheets.Add
  124. On Error Resume Next
  125. ActiveSheet.Name = proName
  126. ActiveSheet.Cells.Select
  127. Selection.FormulaHidden = True
  128. ActiveSheet.Protect Password:="204360", UserInterfaceOnly:=True
  129. Call addDataToSheet(proName, proOwner, proCost, proPeriod, proCostOfCapital)
  130. Call textStatus(0, 0, 0, 0, 0, 1)
  131. Call textBGStatus(0, 0, 0, 0, 0, 1)
  132. Call buttonStatus(0, 1, 0, 0, 1, 0, 1)
  133. Call labelButtonStatus(0, 1, 0, 0, 1, 0, 1)
  134. InvestmentForm.txtCashFlow.SetFocus
  135. End If
  136. createProject = projectName
  137. End Function
  138. Sub addDataToSheet(proName, proOwner, proCost, proPeriod, proCostOfCapital)
  139. With ActiveSheet
  140. .Cells(1, "A").Value = "Project Name"
  141. .Cells(2, "A").Value = "Project Owner"
  142. .Cells(3, "A").Value = "Opportunity Cost"
  143. .Cells(6, "A").Value = "Year"
  144. .Cells(6, "B").Value = "Cash Flow"
  145. .Cells(6, "C").Value = "Accumulate CF"
  146. .Cells(6, "D").Value = "Discounted CF"
  147. .Cells(6, "E").Value = "Accumulate DCF"
  148. End With
  149. Columns("A:E").EntireColumn.AutoFit
  150. Rows(6).HorizontalAlignment = xlCenter
  151. Call addFillColorToCell(proName, proOwner, proCostOfCapital)
  152. Call addCashFlow(proName, proOwner, proCost, proPeriod, proCostOfCapital)
  153. End Sub
  154. Sub addFillColorToCell(proName, proOwner, proCostOfCapital)
  155. Range("C1:E1").Select
  156. Selection.Merge
  157. Selection.Interior.ColorIndex = 36
  158. Selection.Value = proName
  159. Range("C2:E2").Select
  160. Selection.Merge
  161. Selection.Interior.ColorIndex = 40
  162. Selection.Value = proOwner
  163. Range("C3").Select
  164. Selection.Interior.ColorIndex = 34
  165. Selection.Value = proCostOfCapital & " %"
  166. For i = 1 To 4
  167. Range("B6").Select
  168. ActiveCell(1, i).Interior.ColorIndex = 32 + i
  169. Next i
  170. End Sub
  171. Sub addCashFlow(proName, proOwner, proCost, proPeriod, proCostOfCapital, Optional proCash)
  172. num = InvestmentForm.lblNumOfUnit.Caption - 1
  173. Cells(num + 7, "A").Select
  174. ActiveCell.Value = InvestmentForm.lblNumOfUnit.Caption - 1
  175. ActiveCell.HorizontalAlignment = xlCenter
  176. If num = 0 Then
  177. Cells(num + 7, "B").Value = proCost * (-1)
  178. Cells(num + 7, "C").Value = "=RC[-1]"
  179. Cells(num + 7, "D").Value = "=RC[-2]/(1+R3C3)^RC[-3]"
  180. Cells(num + 7, "E").Value = "=RC[-1]"
  181. Else
  182. Cells(num + 7, "B").Value = proCash
  183. Cells(num + 7, "C").Value = "=RC[-1]+R[-1]C"
  184. Cells(num + 7, "D").Value = "=RC[-2]/(1+R3C3)^RC[-3]"
  185. Cells(num + 7, "E").Value = "=RC[-1]+R[-1]C"
  186. End If
  187. beginCell = Cells(num + 7, "B").Address
  188. lastCell = Cells(num + 7, "E").Address
  189. Range(beginCell, lastCell).Select
  190. Selection.NumberFormat = "#,##0.00"
  191. End Sub
  192. Sub previousCashFlow(Optional workingStatus)
  193. atYear = InvestmentForm.lblNumOfUnit.Caption
  194. InvestmentForm.txtCashFlow.Value = Cells(atYear + 7, "B").Value
  195. End Sub
  196. ' ????????????????????? ???????? PP, Discounted PP, NPI, PI ??? IRR
  197. Sub generateResult()
  198. num = InvestmentForm.lblNumOfUnit.Caption
  199. atRow = num + 8
  200. totalRow = Cells(65536, 1).End(xlUp).Row
  201. For numRow = atRow To totalRow
  202. Rows(numRow).Select
  203. Selection.ClearContents
  204. Selection.Clear
  205. Next numRow
  206. Cells(num + 10, "A").Value = "PP"
  207. Call countYearPP(num)
  208. Cells(num + 10, "C").Value = "Year"
  209. Cells(num + 11, "A").Value = "Discounted PP"
  210. Call countYearDPP(num)
  211. Cells(num + 11, "C").Value = "Year"
  212. Cells(num + 12, "A").Value = "NPV"
  213. Cells(num + 12, "B").Value = "=SUM(R7C4:R[-5]C4)"
  214. Cells(num + 12, "C").Value = "Baht"
  215. Cells(num + 13, "A").Value = "PI"
  216. Cells(num + 13, "B").Value = "=R[-1]C/(-1*R7C4)+1"
  217. Cells(num + 13, "B").NumberFormat = "#,##0.00"
  218. Cells(num + 13, "C").Value = "Baht"
  219. Cells(num + 14, "A").Value = "IRR"
  220. Cells(num + 14, "B").Value = "=IRR(R7C2:R[-7]C)"
  221. Cells(num + 14, "B").NumberFormat = "0.00%"
  222. For i = 1 To 5
  223. Cells(num + 10, "A").Select
  224. ActiveCell(i, 1).Interior.ColorIndex = 32 + i
  225. Next i
  226. On Error Resume Next
  227. If TypeName(Cells(num + 14, "B").Value) <> "Double" Then Cells(num + 14, "B").Value = 0
  228. InvestmentForm.lblNumOfUnit.Caption = 1
  229. End Sub
  230. ' ? ???????????????????? ??????????????????????????????????????
  231. Sub countYearPP(num)
  232. For i = 0 To num
  233. Cells(7 + i, "C").Select
  234. Accumulate = ActiveCell.Value
  235. If Sgn(Accumulate) = 1 Then Exit For
  236. Next i
  237. ActiveCell.Value = "=R[-1]C[-2]+(Abs(R[-1]C)/RC[-1])"
  238. totalYear = ActiveCell.Text
  239. Cells(num + 10, "B").Value = totalYear
  240. ActiveCell.Value = "=RC[-1]+R[-1]C"
  241. End Sub
  242. ' ? ???????????????????? ?????????????????????????????????
  243. Sub countYearDPP(num)
  244. For i = 0 To num
  245. Cells(7 + i, "E").Select
  246. Accumulate = ActiveCell.Value
  247. If Sgn(Accumulate) = 1 Then Exit For
  248. Next i
  249. ActiveCell.Value = "=R[-1]C[-4]+(Abs(R[-1]C)/RC[-1])"
  250. totalYear = ActiveCell.Text
  251. Cells(num + 11, "B").Value = totalYear
  252. ActiveCell.Value = "=RC[-1]+R[-1]C"
  253. End Sub
  254. ' ???????????? ???????? “????????????????” ?????????????????????????
  255. Sub createProjectAnalysis(proName)
  256. Dim analysisSheet As Worksheet
  257. For Each analysisSheet In Worksheets
  258. If analysisSheet.Name = "ProjAnalysis" Then
  259. projectAnalysis = "Yes"
  260. Exit For
  261. End If
  262. Next analysisSheet
  263. If projectAnalysis <> "Yes" Then
  264. Application.Worksheets.Add
  265. On Error Resume Next
  266. ActiveSheet.Name = "ProjAnalysis"
  267. ActiveSheet.Protect Password:="204360", UserInterfaceOnly:=True
  268. Rows(2).HorizontalAlignment = xlCenter
  269. Cells(1, "A").Value = "ProjAnalysis"
  270. Cells(1, "A").Interior.ColorIndex = 44
  271. Cells(2, "A").Value = "Project Name"
  272. Cells(2, "B").Value = "Investment"
  273. Cells(2, "C").Value = "WACC"
  274. Cells(2, "D").Value = "YEAR"
  275. Cells(2, "E").Value = "PP"
  276. Cells(2, "F").Value = "DIscounted PP"
  277. Cells(2, "G").Value = "NPV"
  278. Cells(2, "H").Value = "PI"
  279. Cells(2, "I").Value = "IRR"
  280. Range("A2:I2").Interior.ColorIndex = 34
  281. Range("A2:I2").Select
  282. Call cellBorder("VBorder")
  283. End If
  284. Worksheets(proName).Select
  285. End Sub
  286. ' ??????????????????????
  287. Sub cellBorder(Optional styleBorderV As String, Optional styleBorderH As String)
  288. With Selection.Borders(xlEdgeLeft)
  289. .LineStyle = xlContinuous
  290. .Weight = xlThin
  291. .ColorIndex = xlAutomatic
  292. End With
  293. With Selection.Borders(xlEdgeTop)
  294. .LineStyle = xlContinuous
  295. .Weight = xlThin
  296. .ColorIndex = xlAutomatic
  297. End With
  298. With Selection.Borders(xlEdgeBottom)
  299. .LineStyle = xlContinuous
  300. .Weight = xlThin
  301. .ColorIndex = xlAutomatic
  302. End With
  303. With Selection.Borders(xlEdgeRight)
  304. .LineStyle = xlContinuous
  305. .Weight = xlThin
  306. .ColorIndex = xlAutomatic
  307. End With
  308. If styleBorderV = "VBorder" Then
  309. With Selection.Borders(xlInsideVertical)
  310. .LineStyle = xlContinuous
  311. .Weight = xlThin
  312. .ColorIndex = xlAutomatic
  313. End With
  314. End If
  315. If styleBorderH = "HBorder" Then
  316. With Selection.Borders(xlInsideHorizontal)
  317. .LineStyle = xlContinuous
  318. .Weight = xlThin
  319. .ColorIndex = xlAutomatic
  320. End With
  321. End If
  322. End Sub
  323. Sub InvestmentAnalysis(proName, proPeriod)
  324. Application.Worksheets("ProjAnalysis").Select
  325. With Worksheets("ProjAnalysis")
  326. startRow = .Cells(1, 1).End(xlDown).Row
  327. totalRow = .Cells(65536, 1).End(xlUp).Row
  328. For numRow = startRow + 1 To totalRow
  329. .Rows(numRow).Select
  330. Selection.ClearContents
  331. Selection.Clear
  332. Next numRow
  333. End With
  334. Call addDataProjectAnalysis(proName, proPeriod)
  335. nextRow = Worksheets("ProjAnalysis").Cells(65536, 1).End(xlUp).Row + 3
  336. Worksheets("ProjAnalysis").Select
  337. Cells(nextRow, "A").Value = "Project Analysis From"
  338. Cells(nextRow, "A").Interior.ColorIndex = 44
  339. Call investmentTable(nextRow + 1, "PP", 34, "Minimum is", "=MIN(R3C:R[-4]C)", "E", -3)
  340. Call investmentTable(nextRow + 2, "Discount PP", 34, "Minimum is", "=MIN(R3C[1]:R[-5]C[1])", "F", -4)
  341. Call investmentTable(nextRow + 3, "NPV", 34, "Maximum is", "=MAX(R3C[2]:R[-6]C[2])", "G", -5)
  342. Call investmentTable(nextRow + 4, "PI", 34, "Maximum is", "=MAX(R3C[3]:R[-7]C[3])", "H", -6)
  343. Call investmentTable(nextRow + 5, "IRR", 34, "Maximum is", "=MAX(R3C[4]:R[-8]C[4])", "I", -7)
  344. beginCell = Cells(nextRow + 1, "A").Address
  345. lastCell = Cells(nextRow + 5, "E").Address
  346. Range(beginCell, lastCell).Select
  347. Call cellBorder("VBorder", "HBorder")
  348. beginCell = Cells(nextRow + 1, "B").Address
  349. lastCell = Cells(nextRow + 5, "D").Address
  350. Range(beginCell, lastCell).Select
  351. Selection.HorizontalAlignment = xlCenter
  352. Call decisionTable
  353. Worksheets(proName).Select
  354. End Sub
  355. ' ????????????????????????? “???????????????????????” ???????????????????????????
  356. Sub addDataProjectAnalysis(proName, proPeriod)
  357. nextRow = Worksheets("ProjAnalysis").Cells(65536, 1).End(xlUp).Row + 1
  358. With Worksheets("ProjAnalysis")
  359. .Cells(nextRow, "A").Value = Worksheets(proName).Range("C1").Text
  360. .Cells(nextRow, "B").Value = Abs(Worksheets(proName).Range("B7").Text)
  361. .Cells(nextRow, "B").NumberFormat = "#,##0.00"
  362. .Cells(nextRow, "C").Value = Worksheets(proName).Range("C3").Text
  363. .Cells(nextRow, "D").Value = proPeriod
  364. totalRow = Worksheets(proName).Cells(65536, 1).End(xlUp).Row
  365. .Cells(nextRow, "E").Value = Worksheets(proName).Cells(totalRow - 4, "B").Text
  366. .Cells(nextRow, "F").Value = Worksheets(proName).Cells(totalRow - 3, "B").Text
  367. .Cells(nextRow, "G").Value = Worksheets(proName).Cells(totalRow - 2, "B").Text
  368. .Cells(nextRow, "H").Value = Worksheets(proName).Cells(totalRow - 1, "B").Text
  369. .Cells(nextRow, "I").Value = Worksheets(proName).Cells(totalRow, "B").Text
  370. beginCell = Cells(nextRow, "A").Address
  371. lastCell = Cells(nextRow, "I").Address
  372. Range(beginCell, lastCell).Select
  373. Call cellBorder("VBorder")
  374. End With
  375. End Sub
  376. ' ????????????????????? 2 ??? "????????????????????"
  377. Sub investmentTable(insertToRow, valueA, colorA, valueB, valueE, compareColumn, disCompare)
  378. Cells(insertToRow, "A").Value = valueA
  379. Cells(insertToRow, "A").Interior.ColorIndex = colorA
  380. Cells(insertToRow, "B").Value = valueB
  381. Cells(insertToRow, "D").Value = "="
  382. Cells(insertToRow, "E").Value = valueE
  383. Call searchCell(insertToRow, compareColumn, disCompare)
  384. End Sub
  385. ' ??????????????????????????????????????????????????????
  386. Sub searchCell(nextRow, compareColumn, disCell)
  387. selectColumn = "E"
  388. valueColumn = "C"
  389. Dim countProject As Integer
  390. firstTable = Worksheets("ProjAnalysis").Cells(1, 1).End(xlDown).Row
  391. For i = 3 To firstTable
  392. If Cells(nextRow, selectColumn).Value = Cells(i, compareColumn).Value Then
  393. Count = Count + 1
  394. Cells(i, compareColumn).Select
  395. If Count = 1 Then
  396. Cells(nextRow, valueColumn).Value = ActiveCell(1, disCell).Value
  397. Else
  398. Cells(nextRow, valueColumn).Value = Cells(nextRow, valueColumn).Value & ", " & ActiveCell(1, disCell).Value
  399. End If
  400. End If
  401. Next i
  402. End Sub
  403. ' ???????????????????????3 ??? “?????????????”
  404. Sub decisionTable()
  405. Worksheets("ProjAnalysis").Select
  406. nextRow = Worksheets("ProjAnalysis").Cells(65536, 1).End(xlUp).Row + 3
  407. Cells(nextRow, "A").Value = "Decision Table"
  408. Cells(nextRow, "A").Interior.ColorIndex = 44
  409. Cells(nextRow + 1, "A").Value = "Project Name"
  410. Cells(nextRow + 1, "A").Interior.ColorIndex = 34
  411. Cells(nextRow + 1, "B").Value = "PP"
  412. Cells(nextRow + 1, "B").Interior.ColorIndex = 34
  413. Cells(nextRow + 1, "C").Value = "Discounted PP"
  414. Cells(nextRow + 1, "C").Interior.ColorIndex = 34
  415. Cells(nextRow + 1, "D").Value = "NPV"
  416. Cells(nextRow + 1, "D").Interior.ColorIndex = 34
  417. Cells(nextRow + 1, "E").Value = "PI"
  418. Cells(nextRow + 1, "E").Interior.ColorIndex = 34
  419. Cells(nextRow + 1, "F").Value = "IRR"
  420. Cells(nextRow + 1, "F").Interior.ColorIndex = 34
  421. Cells(nextRow + 1, "G").Value = "Index Key"
  422. Cells(nextRow + 1, "G").Interior.ColorIndex = 34
  423. Rows(nextRow + 1).HorizontalAlignment = xlCenter
  424. totalProject = Worksheets("ProjAnalysis").Cells(1, 1).End(xlDown).Row
  425. nextRow = Worksheets("ProjAnalysis").Cells(65536, 1).End(xlUp).Row
  426. j = 1
  427. For i = 3 To totalProject
  428. Cells(nextRow + j, "A").Value = Cells(i, "A").Value
  429. Cells(nextRow + j, "G").Value = "=COUNTA(RC[-5]:RC[-1])"
  430. Cells(nextRow + j, "G").HorizontalAlignment = xlCenter
  431. j = j + 1
  432. Next i
  433. beginCell = Cells(nextRow, "A").Address
  434. lastCell = Cells(nextRow + totalProject - 2, "G").Address
  435. Range(beginCell, lastCell).Select
  436. Call cellBorder("VBorder", "HBorder")
  437. Call decisionValue(totalProject - 2, 5, totalProject + 2, 2)
  438. Call decisionValue(totalProject - 2, 6, totalProject + 3, 3)
  439. Call decisionValue(totalProject - 2, 7, totalProject + 4, 4)
  440. Call decisionValue(totalProject - 2, 8, totalProject + 5, 5)
  441. Call decisionValue(totalProject - 2, 9, totalProject + 6, 6)
  442. Columns("A:I").EntireColumn.AutoFit
  443. ActiveWindow.DisplayGridlines = False
  444. End Sub
  445. ' ?????????????????????????????3 ??????????????? ??????????????????? ???????
  446. Sub decisionValue(totalProject, C, R, insertCol)
  447. With ActiveSheet
  448. Range("A3").Select
  449. For i = 1 To totalProject
  450. If ActiveCell(i, C).Value = ActiveCell(R, 5).Value Then
  451. ActiveCell(totalProject + 12 + i, insertCol).Value = "P"
  452. ActiveCell(totalProject + 12 + i, insertCol).Font.Name = "Wingdings 2"
  453. ActiveCell(totalProject + 12 + i, insertCol).HorizontalAlignment = xlCenter
  454. End If
  455. Next i
  456. .Cells.Select
  457. Selection.FormulaHidden = True
  458. .Cells(1, 1).Select
  459. End With
  460. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement