Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding New record
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding New record
If strFund = "MEDICAL" Then
Sheets("AP-Medical").Select do while not isempty(cells(i,j)) i = i + 1 loop Cells(i, j) = strAP Cells(i, j + 1) = sngAmount Else Sheets("AP-Pension").Select do while not isempty(cells(i,j)) i = i + 1 Loop Cells(i, j) = strAP Cells(i, j + 1) = sngAmount End If -- Regards, Tom Ogilvy "Squid" wrote in message ... 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding New record
Thank you. THis is exactly what I needed.
-----Original Message----- If strFund = "MEDICAL" Then Sheets("AP-Medical").Select do while not isempty(cells(i,j)) i = i + 1 loop Cells(i, j) = strAP Cells(i, j + 1) = sngAmount Else Sheets("AP-Pension").Select do while not isempty(cells(i,j)) i = i + 1 Loop Cells(i, j) = strAP Cells(i, j + 1) = sngAmount End If -- Regards, Tom Ogilvy "Squid" wrote in message ... 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 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I need to have a record number change for every record | Excel Discussion (Misc queries) | |||
Open new record with selected fields from previous record | Excel Discussion (Misc queries) | |||
adding cell data to a record | Excel Discussion (Misc queries) | |||
Adding a blank row after a new record changes in excel | Excel Worksheet Functions | |||
Need help autopopulating next new record with previous record data | Excel Programming |