Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Help with Mr. Peterson's Code.. Print serially from a Sheet

The following code works fine for printing as suggested by Mr.
Peterson.
My need now is to send a soft copy to someone...in pdf format and the
following code generates separate file for each instance.

Can it be changed to give print a range of records like in Microsoft
Word...e.g a Range like From Page to To Page

Any help would be appreciated.

Thanks in advance
Rashid Khan

Option Explicit
Private Sub PrintForm()
Dim myRng As Range
Dim myCell As Range
Dim wks As Worksheet
Dim StartVal As Long
Dim EndVal As Long
Dim TempVal As Long
Dim iCtr As Long
Dim myPfx As String

StartVal = CLng(Application.InputBox(prompt:="Start with", _
Default:=1, Type:=1))
If StartVal = 0 Then
Exit Sub
End If
EndVal = CLng(Application.InputBox(prompt:="End with", _
Default:=StartVal + 1, Type:=1))
If EndVal = 0 Then
Exit Sub
End If
If EndVal < StartVal Then
TempVal = StartVal
StartVal = EndVal
EndVal = TempVal
End If
Set wks = ActiveSheet


Select Case LCase(wks.Name)
Case Is = "pc details"
Set myRng = Worksheets("pc").Range("data")
Case Is = "printer form"
Set myRng = Worksheets("printer").Range("data")
Case Is = "monitor form"
Set myRng = Worksheets("monitor").Range("data")
Case Is = "switch form"
Set myRng = Worksheets("switch").Range("data")
Case Is = "router form"
Set myRng = Worksheets("router").Range("data")
Case Is = "firewall form"
Set myRng = Worksheets("firewall").Range("data")
Case Is = "modem form"
Set myRng = Worksheets("modem").Range("data")
Case Is = "scanner form"
Set myRng = Worksheets("scanner").Range("data")
Case Else:
MsgBox "design error with worksheet: " & wks.Name
Exit Sub
End Select

'xxx???yyyyy
myPfx = InputBox(prompt:="what's the prefix")
If Trim(myPfx) = "" Then
Exit Sub
End If
myPfx = Left(myPfx & Space(3), 3) 'pad it with trailing spaces if
required.
Application.EnableEvents = False
For Each myCell In myRng.Cells
If LCase(myCell.Value) Like LCase(myPfx) & "*" Then
If IsNumeric(Mid(myCell.Value, 4, 3)) Then
If StartVal <= Val(Mid(myCell.Value, 4, 3)) _
And EndVal = Val(Mid(myCell.Value, 4, 3)) Then
wks.Range("ID").Value = myCell.Value
'Application.Calculate
wks.Range("PRINTAREA").PrintOut
'wks.Range("PRINTAREA").PrintOut preview:=True
End If
End If
End If
Next myCell
Application.EnableEvents = True
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
Rename Multiple Sheets - Help with Mr Dave Peterson's Code [email protected] Excel Programming 2 January 4th 06 09:16 AM
Help with Mr. Peterson's Code.. Print serially from a Sheet prkhan56 Excel Programming 50 July 31st 05 01:18 PM
Changing code that set's print area...to active sheet only KimberlyC Excel Programming 4 July 10th 05 10:19 PM
how to use Excel to generate alphabet serially Maxwell Excel Worksheet Functions 10 May 7th 05 03:37 PM
Help with Mr. Dave Peterson's Code for Consolidating Many Sheets to One Rashid Khan Excel Programming 2 July 31st 04 07:31 PM


All times are GMT +1. The time now is 04:27 PM.

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

About Us

"It's about Microsoft Excel"