View Single Post
  #45   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Help with Mr. Peterson's Code.. Print serially from a Sheet

Always 3 characters at the beginning...

If yes, then I'd ask for that prefix in another inputbox.

You'll have to add this portion to your current code (I've lost track of what's
current).

dim myPfx as string
.....


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.

Then the other part:

For Each mycell In myRng.Cells
If LCase(mycell.Value) Like LCase(mypf) & "*" 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 'just in case
wks.Range("PRINTAREA").PrintOut preview:=True
.....

End If 'one more end if to match up with that if

End Sub

prkhan56 wrote:

Hi Dave,
Thanks a million...I have ID as sheet level name and it is working but
a slight problem is occurring. May be you would be kind enough to
rectify that too...

Is it possible that I can type the code together with number for
example EFG123 in the start box and EFG145... which would print the
record from 123 to 145 for company EFG. As my numbers repeat also in
some cases like ABC123 to ABC145...

Now the macro prints the same number from all the companies... for eg

When I put 123 in the start box and 145 in the end box.. then it will
print ABC123 to ABC145, and then EFG123 to EFG145... and so on... I
hope you get what I am trying to say.

I have no words to express my thanks for all the time and help you have
extended to me during all these days.

Can the above problem be rectified?
I thing the following needs to be modified :

For Each myCell In myRng.Cells
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 'just in case
wks.Range("PRINTAREA").PrintOut preview:=True

the code should allow me to input the number eg ABC123 in the beginning
box and ABC145 in the second input box... and then print accordingly

Thanks a million once again.

Rashid Khan


--

Dave Peterson