Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable does not fit in PrintArea

Status
Not open for further replies.

jpgactmod

Technical User
Feb 12, 2004
41
US
First, I apologize to anyone who may have seen this question on the Access Forum, where I posted this in error.

I am trying to use a VBA macro to set Excel's Print Range that varies each time the macro is run. The code looks like the following:

For i = 0 to 50
PrRng = PrRng & "," & "AI" & 2 + 175 * i & ":" & "AU" & 65 + 175 * i _
& "," & "AI" & 68 + 175 * iMkt & ":" & "AU" & 131 + 175 * i
next i

With ActiveSheet.PageSetup
.PrintArea = PrRng
End With

As you can see, the string variable "PrRng" can get quite large. In fact, so large that Excel's PrintArea apparently cannot handle the length of the variable so I get an error message.

Can anyone think of a work around or a trick to get PrintArea to accept a very large string variable? I am trying to print out a large report with page numbers.

Thank you for any help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top