Private Sub CommandButton2_Click() 'Tax Form Button - captures all sales for year
Sheet3.Activate
ActiveSheet.Unprotect
Dim lastrow3 As Long
lastrow3 = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row
If Cells(4, "A") = "" Then
Else
Sheets("Sheet3").Range(Cells(4, "A"), Cells(lastrow3, "H")).Select
Selection = ""
Sheets("Sheet3").Range(Cells(lastrow3, "B"), Cells(lastrow3, "H")).Select
With Selection.Borders(xlEdgeTop)
.LineStyle = none
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = none
End With
End If
Sheet1.Activate
Dim i As Integer, rng As Range
Dim lastrow As Long, nextrow As Long
Dim Title As String
Title = ("MY WESTJET SHARES - TAX REPORT FOR " & TextBox1.Text)
lastrow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
nextrow = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row + 1
Set rng = Sheets("Sheet1").Range("T4:T" & lastrow)
For i = 4 To lastrow
If Cells(i, "T").Value = TextBox1.Text And Cells(i, "C").Value = "Sell" Then
'Range(Cells(i, "A"), Cells(i, "L")).Copy Destination:=Sheets("Sheet3").Cells(nextrow, "A")
Sheets("Sheet3").Cells(nextrow, "A").Value = Range(Cells(i, "A"), Cells(i, "A")).Value 'Date
Sheets("Sheet3").Cells(nextrow, "B").Value = Range(Cells(i, "E"), Cells(i, "E")).Value 'Share Price
Sheets("Sheet3").Cells(nextrow, "C").Value = Range(Cells(i, "G"), Cells(i, "G")).Value '#Shares Sold
Sheets("Sheet3").Cells(nextrow, "D").Value = Range(Cells(i, "I"), Cells(i, "I")).Value 'Price Sold For
Sheets("Sheet3").Cells(nextrow, "E").Value = Range(Cells(i, "K"), Cells(i, "K")).Value 'ACB/Share
Sheets("Sheet3").Cells(nextrow, "G").Value = Range(Cells(i, "J"), Cells(i, "J")).Value 'Capital Gain/Loss
Sheets("Sheet3").Cells(nextrow, "H").Value = Range(Cells(i, "D"), Cells(i, "D")).Value 'Sales Fee
Sheets("Sheet3").Cells(nextrow, "I").Value = Range(Cells(i, "P"), Cells(i, "P")).Value 'Date 1st
Sheets("Sheet3").Cells(nextrow, "J").Value = Range(Cells(i, "Q"), Cells(i, "Q")).Value 'Date last
'Sheets("Sheet3").Cells(nextrow, "I").Value = Range(Cells(i, "I"), Cells(i, "L")).Value
'Sheets("Sheet3").Cells(nextrow, "J").Value = Range(Cells(i, "J"), Cells(i, "L")).Value
'Sheets("Sheet3").Cells(nextrow, "K").Value = Range(Cells(i, "K"), Cells(i, "L")).Value
'Sheets("Sheet3").Cells(nextrow, "A").Resize(1, 12).Value = Range(Cells(i, "A"), Cells(i, "L")).Value
nextrow = nextrow + 1
End If
Next i
Sheet3.Activate
Dim EndRow As Long
EndRow = Sheet3.Cells(Rows.Count, "A").End(xlUp).Row
Cells(EndRow + 1, 1).Value = "Totals"
Dim r As Long
r = Cells(Rows.Count, "B").End(xlUp).Row
Range("F2").Copy
Range("F2").AutoFill Destination:=Range("F2", ("F4:F" & EndRow))
Cells(3, "F").Value = "Adj. Cost Base"
Cells(EndRow + 1, 3).FormulaR1C1 = "=SUM(R1C:R" & EndRow & "C)"
Cells(EndRow + 1, 4).FormulaR1C1 = "=SUM(R1C:R" & EndRow & "C)"
Cells(EndRow + 1, 6).FormulaR1C1 = "=SUM(R1C:R" & EndRow & "C)"
Cells(EndRow + 1, 7).FormulaR1C1 = "=SUM(R1C:R" & EndRow & "C)"
Cells(EndRow + 1, 8).FormulaR1C1 = "=SUM(R1C:R" & EndRow & "C)"
Cells(1, 5).Value = Title
'Range("A" & Rows.Count).End(xlUp).Select
Sheets("Sheet3").Range(Cells(nextrow, "B"), Cells(nextrow, "H")).Select
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.ColorIndex = xlAutomatic
.Weight = xlThick
End With
Range("A" & Rows.Count).End(xlUp).Select 'Selects the last cell in column A (used to deselect previous selection)
'Unload Me
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
REPORTS.CommandButton3.Visible = True
End Sub
Bookmarks