Skip to content

Commit

Permalink
Saving vba script for sub2 analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
jhustles committed Mar 18, 2020
1 parent 9b64763 commit 72edec7
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion VBA_Script_JG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,32 @@ Sub Analysis_2()
TotalOpenPrice = TotalOpenPrice + ws.Cells(Row, 3).Value
TotalClosePrice = TotalClosePrice + ws.Cells(Row, 6).Value
TotalYearlyChange = (TotalClosePrice - TotalOpenPrice)
TotalStkVol = TotalStkVol + ws.Cells(Row, 7).Value
TotalStkVol = TotalStkVol + ws.Cells(Row, 7).Value

'Print Ticker Name in the Summary Table
ws.Range("I" & SummaryTableTick2).Value = Ticker

'Print "YEARLY CHANGE" to Summary Table
ws.Range("J" & SummaryTableTick2).Value = TotalYearlyChange

'setting up condition that if the total yearly change is positive color the interior green
'otherwise if negative, color the interior red
If (TotalYearlyChange > 0) Then
ws.Range("J" & SummaryTableTick2).Interior.ColorIndex = 4
ElseIf (TotalYearlyChange = 0) Then
ws.Range("J" & SummaryTableTick2).Interior.ColorIndex = 2
Else
ws.Range("J" & SummaryTableTick2).Interior.ColorIndex = 3
End If

'Total PERCENT CHANGE - Need to account for If TotalYearlyChange = 0 (will cause an error)
If (TotalYearlyChange = 0) Then
ws.Range("K" & SummaryTableTick2).Value = 0
Else

'Print "Percent Change" to Summary Table = (totalcloseprice - totalopenprice)/ totalopenprice)
ws.Range("K" & SummaryTableTick2).Value = TotalYearlyChange / TotalOpenPrice

'Change format for Total Percentage Change to Percent style
ws.Range("K" & SummaryTableTick2).Style = "Percent"
End If

0 comments on commit 72edec7

Please sign in to comment.