ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro using relative references (https://www.excelbanter.com/excel-worksheet-functions/207119-macro-using-relative-references.html)

warp9

Macro using relative references
 
Im trying to record a macro using the relative reference option in order to
change the print area every time its run. The active cell offset reference
appears in the code, yet the print range defaults to the original print area
regardless of where the cursor is placed when the macro is run. What am I
doing wrong?

John C[_2_]

Macro using relative references
 
A snippet of your code would be helpful.
--
John C


"warp9" wrote:

Im trying to record a macro using the relative reference option in order to
change the print area every time its run. The active cell offset reference
appears in the code, yet the print range defaults to the original print area
regardless of where the cursor is placed when the macro is run. What am I
doing wrong?


warp9

Macro using relative references
 
Thanks John.


ActiveCell.Offset(3, 0).Range("A1:M100").Select
ActiveSheet.PageSetup.PrintArea = "$A$701:$M$800"

"John C" wrote:

A snippet of your code would be helpful.
--
John C


"warp9" wrote:

Im trying to record a macro using the relative reference option in order to
change the print area every time its run. The active cell offset reference
appears in the code, yet the print range defaults to the original print area
regardless of where the cursor is placed when the macro is run. What am I
doing wrong?


John C[_2_]

Macro using relative references
 
Your code is selecting A1:M100, but then printing A701:M800 only.

Change your second line to this:
ActiveSheet.PageSetup.PrintArea = Selection.Address

Hope this helps.
--
John C


"warp9" wrote:

Thanks John.


ActiveCell.Offset(3, 0).Range("A1:M100").Select
ActiveSheet.PageSetup.PrintArea = "$A$701:$M$800"

"John C" wrote:

A snippet of your code would be helpful.
--
John C


"warp9" wrote:

Im trying to record a macro using the relative reference option in order to
change the print area every time its run. The active cell offset reference
appears in the code, yet the print range defaults to the original print area
regardless of where the cursor is placed when the macro is run. What am I
doing wrong?


warp9

Macro using relative references
 
Awesome John. Thanks! I tried it several times and it works perfectly.

"John C" wrote:

Your code is selecting A1:M100, but then printing A701:M800 only.

Change your second line to this:
ActiveSheet.PageSetup.PrintArea = Selection.Address

Hope this helps.
--
John C


"warp9" wrote:

Thanks John.


ActiveCell.Offset(3, 0).Range("A1:M100").Select
ActiveSheet.PageSetup.PrintArea = "$A$701:$M$800"

"John C" wrote:

A snippet of your code would be helpful.
--
John C


"warp9" wrote:

Im trying to record a macro using the relative reference option in order to
change the print area every time its run. The active cell offset reference
appears in the code, yet the print range defaults to the original print area
regardless of where the cursor is placed when the macro is run. What am I
doing wrong?


John C[_2_]

Macro using relative references
 
Thanks for the feedback :)
--
John C


"warp9" wrote:

Awesome John. Thanks! I tried it several times and it works perfectly.

"John C" wrote:

Your code is selecting A1:M100, but then printing A701:M800 only.

Change your second line to this:
ActiveSheet.PageSetup.PrintArea = Selection.Address

Hope this helps.
--
John C


"warp9" wrote:

Thanks John.


ActiveCell.Offset(3, 0).Range("A1:M100").Select
ActiveSheet.PageSetup.PrintArea = "$A$701:$M$800"

"John C" wrote:

A snippet of your code would be helpful.
--
John C


"warp9" wrote:

Im trying to record a macro using the relative reference option in order to
change the print area every time its run. The active cell offset reference
appears in the code, yet the print range defaults to the original print area
regardless of where the cursor is placed when the macro is run. What am I
doing wrong?



All times are GMT +1. The time now is 04:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com