Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Setting Print Area

Hello,

I am using Excel 2003. I would appreciate it greatly if someone could
assist me with a macro to set my print area. I have 17 columns (with 16
being visible) full of data and varying rows each time that my report is
created. I have sorted on column 3 (increasing) as this column contains any
number from 0 to 3000 or more. I would like the code to set and limit the
print area to rows to include integers 0 to 200. Anything 200 is not to be
included in the print area. I have a header also.

Thanks for any assistance that you can provide.
--
By persisting in your path, though you forfeit the little, you gain the
great.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Setting Print Area

Sub Macro1()
For i = 1 To Rows.Count
If Cells(i, "G").Value 200 Then
Exit For
End If
Next
i = i - 1
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
End Sub

This assumes that your 17 columns are columns A thru Q

--
Gary''s Student - gsnu200828


"DavidH56" wrote:

Hello,

I am using Excel 2003. I would appreciate it greatly if someone could
assist me with a macro to set my print area. I have 17 columns (with 16
being visible) full of data and varying rows each time that my report is
created. I have sorted on column 3 (increasing) as this column contains any
number from 0 to 3000 or more. I would like the code to set and limit the
print area to rows to include integers 0 to 200. Anything 200 is not to be
included in the print area. I have a header also.

Thanks for any assistance that you can provide.
--
By persisting in your path, though you forfeit the little, you gain the
great.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Setting Print Area

Thanks for your quick response Gary's Student. I tried running the code I
used "C" instead of "G" because the integer would be in this column. I got a
runtime - unable to set printarea property to the pagesetup class and this
line was highlighted yellow:
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
--
By persisting in your path, though you forfeit the little, you gain the
great.



"Gary''s Student" wrote:

Sub Macro1()
For i = 1 To Rows.Count
If Cells(i, "G").Value 200 Then
Exit For
End If
Next
i = i - 1
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
End Sub

This assumes that your 17 columns are columns A thru Q

--
Gary''s Student - gsnu200828


"DavidH56" wrote:

Hello,

I am using Excel 2003. I would appreciate it greatly if someone could
assist me with a macro to set my print area. I have 17 columns (with 16
being visible) full of data and varying rows each time that my report is
created. I have sorted on column 3 (increasing) as this column contains any
number from 0 to 3000 or more. I would like the code to set and limit the
print area to rows to include integers 0 to 200. Anything 200 is not to be
included in the print area. I have a header also.

Thanks for any assistance that you can provide.
--
By persisting in your path, though you forfeit the little, you gain the
great.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Setting Print Area

I used the code that GS posted and made the change to column C. I filled
column C with values from 0 to greater than 200 and ran the code. It set a
print area for A1:Q201, which appears to be the correct range. No error
messages were displayed. Check your code to be sure you did not omit commas
or quiotation marks and that you did not inadvertantly add something that
should not be in there.

"DavidH56" wrote:

Thanks for your quick response Gary's Student. I tried running the code I
used "C" instead of "G" because the integer would be in this column. I got a
runtime - unable to set printarea property to the pagesetup class and this
line was highlighted yellow:
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
--
By persisting in your path, though you forfeit the little, you gain the
great.



"Gary''s Student" wrote:

Sub Macro1()
For i = 1 To Rows.Count
If Cells(i, "G").Value 200 Then
Exit For
End If
Next
i = i - 1
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
End Sub

This assumes that your 17 columns are columns A thru Q

--
Gary''s Student - gsnu200828


"DavidH56" wrote:

Hello,

I am using Excel 2003. I would appreciate it greatly if someone could
assist me with a macro to set my print area. I have 17 columns (with 16
being visible) full of data and varying rows each time that my report is
created. I have sorted on column 3 (increasing) as this column contains any
number from 0 to 3000 or more. I would like the code to set and limit the
print area to rows to include integers 0 to 200. Anything 200 is not to be
included in the print area. I have a header also.

Thanks for any assistance that you can provide.
--
By persisting in your path, though you forfeit the little, you gain the
great.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Setting Print Area

Thanks JLGWhiz for your input. I went back and tried it again ans still got
the error message. I then tweaked it just a little and this is the code that
worked for me.

Sub Macro1()
For i = 2 To Rows.Count
If Cells(i, "G").Value 200 Then
Exit For
End If
Next
i = i - 1
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
End Sub

Again thank you GS for solving my problem.
--
By persisting in your path, though you forfeit the little, you gain the
great.



"JLGWhiz" wrote:

I used the code that GS posted and made the change to column C. I filled
column C with values from 0 to greater than 200 and ran the code. It set a
print area for A1:Q201, which appears to be the correct range. No error
messages were displayed. Check your code to be sure you did not omit commas
or quiotation marks and that you did not inadvertantly add something that
should not be in there.

"DavidH56" wrote:

Thanks for your quick response Gary's Student. I tried running the code I
used "C" instead of "G" because the integer would be in this column. I got a
runtime - unable to set printarea property to the pagesetup class and this
line was highlighted yellow:
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
--
By persisting in your path, though you forfeit the little, you gain the
great.



"Gary''s Student" wrote:

Sub Macro1()
For i = 1 To Rows.Count
If Cells(i, "G").Value 200 Then
Exit For
End If
Next
i = i - 1
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
End Sub

This assumes that your 17 columns are columns A thru Q

--
Gary''s Student - gsnu200828


"DavidH56" wrote:

Hello,

I am using Excel 2003. I would appreciate it greatly if someone could
assist me with a macro to set my print area. I have 17 columns (with 16
being visible) full of data and varying rows each time that my report is
created. I have sorted on column 3 (increasing) as this column contains any
number from 0 to 3000 or more. I would like the code to set and limit the
print area to rows to include integers 0 to 200. Anything 200 is not to be
included in the print area. I have a header also.

Thanks for any assistance that you can provide.
--
By persisting in your path, though you forfeit the little, you gain the
great.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Setting Print Area

Oops, Actually this is the correct code:

Sub Macro1()
For i = 2 To Rows.Count
If Cells(i, "C").Value 200 Then
Exit For
End If
Next
i = i - 1
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
End Sub

--
By persisting in your path, though you forfeit the little, you gain the
great.



"DavidH56" wrote:

Thanks JLGWhiz for your input. I went back and tried it again ans still got
the error message. I then tweaked it just a little and this is the code that
worked for me.

Sub Macro1()
For i = 2 To Rows.Count
If Cells(i, "G").Value 200 Then
Exit For
End If
Next
i = i - 1
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
End Sub

Again thank you GS for solving my problem.
--
By persisting in your path, though you forfeit the little, you gain the
great.



"JLGWhiz" wrote:

I used the code that GS posted and made the change to column C. I filled
column C with values from 0 to greater than 200 and ran the code. It set a
print area for A1:Q201, which appears to be the correct range. No error
messages were displayed. Check your code to be sure you did not omit commas
or quiotation marks and that you did not inadvertantly add something that
should not be in there.

"DavidH56" wrote:

Thanks for your quick response Gary's Student. I tried running the code I
used "C" instead of "G" because the integer would be in this column. I got a
runtime - unable to set printarea property to the pagesetup class and this
line was highlighted yellow:
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
--
By persisting in your path, though you forfeit the little, you gain the
great.



"Gary''s Student" wrote:

Sub Macro1()
For i = 1 To Rows.Count
If Cells(i, "G").Value 200 Then
Exit For
End If
Next
i = i - 1
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$" & i
End Sub

This assumes that your 17 columns are columns A thru Q

--
Gary''s Student - gsnu200828


"DavidH56" wrote:

Hello,

I am using Excel 2003. I would appreciate it greatly if someone could
assist me with a macro to set my print area. I have 17 columns (with 16
being visible) full of data and varying rows each time that my report is
created. I have sorted on column 3 (increasing) as this column contains any
number from 0 to 3000 or more. I would like the code to set and limit the
print area to rows to include integers 0 to 200. Anything 200 is not to be
included in the print area. I have a header also.

Thanks for any assistance that you can provide.
--
By persisting in your path, though you forfeit the little, you gain the
great.

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
Setting The Print-Area ? Robert11[_3_] New Users to Excel 2 May 31st 09 03:24 PM
Setting print area richzip Excel Discussion (Misc queries) 1 April 27th 08 08:10 AM
Setting Print Area Mike[_122_] Excel Programming 3 November 28th 07 03:31 PM
Setting Print Area dolppm Excel Programming 2 March 8th 05 09:35 PM
Setting print area with vba KimberlyC Excel Programming 3 December 18th 04 12:46 AM


All times are GMT +1. The time now is 05:17 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"