• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Expanding Print area preview with a current macro

Don Black

New Member
I recently posted a macro that I received help from excel ninja member HUI, which works great.
my only problem, now is that the print area preview does not expand when the populated cells are created thus rendering the back button to be disabled until I manual adjust the print area preview.

here is a macro I found to expand the print area preview just not sure how to combine the two macros into one or if this new macro should be placed in a module.

Code:
Sub Set_Print_Area()
Dim x As Long, lastCell As Range
x = ActiveSheet.UsedRange.Columns.Count
Set lastCell = Cells.SpecialCells(xlCellTypeLastCell)
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), lastCell).Address
End Sub


here is the link for my other macro to reference what I am trying to do.
http://chandoo.org/forum/threads/delete-add-rows-from-referenced-worksheet.15192/
 
Hi, Don Black!

Hui's procedure has nothing related with printing configuration or printing issues, it just deletes #REF# data. So you could easily place this new code at the end of Hui's one.

That in the case that you actually need a code like this new one, that you'll do if you have a previously set print area because you didn't want to print the whole worksheet. For printing the whole ws, clear the print area and forget about this new code.

Regards!
 
Hi, Don Black!

I didn't test your provided macro, just read what it was supposed to do and analyzed Hui's code to check how they could interact.

Have you tested your macro on the same worksheet where the other operates on? Does it work fine? If so I don't see why they wouldn't work together, else did you check it with the source?

Regards!
 
Hi, Don Black!
Then your provided macro doesn't work, if I understand correctly. This changes your thread issue description from merging codes.
Consider posting the related sample file.
Regards!
 
I tested the code in a separate worksheet and it worked it expand the sides of the print area, I don't the width to expand only the height I guess it has to be placed in a module, but I want it to be triggered only when my macro has completed.
 
Hi, Don Black!
Without the file the only thing I can see is that it's operating on the Activesheet worksheet, nothing more, os check that. If you say it works, I believe you, but I won't test it without a sample file. And if it works then you could simply add it at then end of Hui's code. If you can't get it working and you're not willing to upload the file, maybe someone else who read this could see what I don't and hence would be able to help you.
Regards!
 
Back
Top