PDA

View Full Version : Solved: Print: How to get Data to Print



coliervile
02-21-2008, 04:39 PM
The following worksheet allows employees' to submit time off of work, vacation and other types of time away from work. There are three (3) command buttons; Submit Leave Request Form, Search For Leave By Date and Search For Leave By Name. The command buttons are pretty much self explanatory. When a user uses the "Search For Leave By Date" they place the date in the search box (e.g. 9/5/08) and any names, types and when requested display in a message box (msgbox).... see below. Most of these codings where a product of "XLD"...thanks again for your help.

---------------------------
Microsoft Excel
---------------------------
GG (Leave type: Prime Time, Requested on: 15 Feb 2008 16:04:53)

EE (Leave type: Annual, Requested on: 15 Feb 2008 16:05:22)

CC (Leave type: Prime Time, Requested on: 15 Feb 2008 16:05:44)

BB (Leave type: Annual, Requested on: 15 Feb 2008 16:06:05)

FF (Leave type: Sick, Requested on: 16 Feb 2008 22:06:39)


---------------------------
OK
---------------------------

What I want to do is be able to print this information out...

GG (Leave type: Prime Time, Requested on: 15 Feb 2008 16:04:53)

EE (Leave type: Annual, Requested on: 15 Feb 2008 16:05:22)

CC (Leave type: Prime Time, Requested on: 15 Feb 2008 16:05:44)

BB (Leave type: Annual, Requested on: 15 Feb 2008 16:06:05)

FF (Leave type: Sick, Requested on: 16 Feb 2008 22:06:39)

Any ideas of how to do this from a message box???

I would also like to add to the message box the date that was requested in the search text box???

Best regards,

Charlie

mdmackillop
02-21-2008, 04:56 PM
I would write the results to another location and print it out.

coliervile
02-21-2008, 05:00 PM
Thank for you response. If I added another worksheet named "Printout" how would you write the results to it???

Best regards,

Charlie

coliervile
02-21-2008, 06:07 PM
I solved my issue of placing the search date in the message box with this coding;

If mpRows(i, 1) <> False Then

mpMessage = mpMessage & mpTestDate & " " & mpNames.Cells(i, 1).Value & _
" (Leave type: " & mpNames.Cells(i, 3).Value & _
", Requested on: " & mpNames.Cells(i, 2).Text & ")" & vbNewLine & vbNewLine

End If

Best regards,

Charlie

coliervile
02-22-2008, 09:51 AM
I think I solved my issue with the following coding that copies the data searched for to another worksheet "Printout". This would allow the user to printout the information searched for. Please take a look and see if this is correct and/or an easier way??? I used this coding (in BLUE) in the "Quick Search For Leave By Name":

If .Cells(i, "A").Value = mpTestName Then


mpMessage = mpMessage & mpNames.Cells(i, 1).Value & _
" (Requested on: " & mpNames.Cells(i, 2).Text & ", Leave type: " & mpNames.Cells(i, 3).Value & _
", Start Date on: " & mpNames.Cells(i, 4).Text & ", End Date on: " & mpNames.Cells(i, 5).Text & ")" & vbNewLine & vbNewLine

LastRowPrintout = Worksheets("Printout").Range("A" & Rows.Count).End(xlUp).Row
Rows(i).Copy Worksheets("Printout").Range("A" & LastRowPrintout + 1)
End If

I used this coding (in BLUE) in the "Quick Search For Leave By Date":

If mpRows(i, 1) <> False Then

mpMessage = mpMessage & "Requested" & " " & mpTestDate & " " & "Off- " & " " & mpNames.Cells(i, 1).Value & _
" (Leave type: " & mpNames.Cells(i, 3).Value & _
", Requested on: " & mpNames.Cells(i, 2).Text & ")" & vbNewLine & vbNewLine

LastRowPrintout = Worksheets("Printout").Range("A" & Rows.Count).End(xlUp).Row
Rows(i).Copy Worksheets("Printout").Range("A" & LastRowPrintout + 1)

End If

If there's a better way or if I missed something please let me know??? Always egar to learn more.... :beerchug:

Best regards,

Charlie