Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to have a record number change for every record Puget Sound Courier Service Excel Discussion (Misc queries) 1 July 12th 09 03:32 PM
Open new record with selected fields from previous record Design by Sue Excel Discussion (Misc queries) 1 June 12th 09 02:24 PM
adding cell data to a record MikeH Excel Discussion (Misc queries) 2 October 30th 08 10:20 PM
Adding a blank row after a new record changes in excel Skyblue Excel Worksheet Functions 1 August 8th 08 04:24 AM
Need help autopopulating next new record with previous record data Harry S[_3_] Excel Programming 2 October 1st 03 10:59 PM


All times are GMT +1. The time now is 07:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"