S
Squid
I have a spreadsheet, where I need to copy certain cell
values and place into a separate sheet. I want this occur
in the BeforePrint event. So, when the user prints the
Check worksheet, the code will populate the specific
sheets with the proper cells values and then position the
cell to the next row. When the user again prints, new data
could be added to the specific sheet without overwriting
the previous data.
Below is the code i have so far, but it is not working.
Could someone please help me?
Thanks.. Mike
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim strFund As String
Dim strAP As String
Dim sngAmount As Single
Dim i As Integer ' Row
Dim j As Integer ' Column
strFund = Worksheets("Check Worksheet").Range("J2").Value
strAP = Worksheets("Check Worksheet").Range("C14").Value
sngAmount = Worksheets("Check Worksheet").Range
("C22").Value
i = 2 'Row
j = 1 'Column
If strFund = "MEDICAL" Then
Sheets("AP-Medical").Select
Range.Cells(i, j) = strAP
Range.Cells(i, j + 1) = sngAmount
i = i + 1
Else
Sheets("AP-Pension").Select
Range.Cells(i, j) = strAP
Range.Cells(i, j + 1) = sngAmount
i = i + 1
End If
End Sub
values and place into a separate sheet. I want this occur
in the BeforePrint event. So, when the user prints the
Check worksheet, the code will populate the specific
sheets with the proper cells values and then position the
cell to the next row. When the user again prints, new data
could be added to the specific sheet without overwriting
the previous data.
Below is the code i have so far, but it is not working.
Could someone please help me?
Thanks.. Mike
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim strFund As String
Dim strAP As String
Dim sngAmount As Single
Dim i As Integer ' Row
Dim j As Integer ' Column
strFund = Worksheets("Check Worksheet").Range("J2").Value
strAP = Worksheets("Check Worksheet").Range("C14").Value
sngAmount = Worksheets("Check Worksheet").Range
("C22").Value
i = 2 'Row
j = 1 'Column
If strFund = "MEDICAL" Then
Sheets("AP-Medical").Select
Range.Cells(i, j) = strAP
Range.Cells(i, j + 1) = sngAmount
i = i + 1
Else
Sheets("AP-Pension").Select
Range.Cells(i, j) = strAP
Range.Cells(i, j + 1) = sngAmount
i = i + 1
End If
End Sub