Hi,

Try below codes,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
With Worksheets(1).PageSetup
    .LeftMargin = Application.InchesToPoints(0.05)
    .RightMargin = Application.InchesToPoints(0.05)
    .TopMargin = Application.InchesToPoints(0.05)
    .BottomMargin = Application.InchesToPoints(0.05)
    .HeaderMargin = Application.InchesToPoints(0.05)
    .FooterMargin = Application.InchesToPoints(0.05)
*    .Zoom = 150*
*    .CenterHorizontally = True*
    End With
Application.ScreenUpdating = True
End Sub


On Tue, May 8, 2012 at 9:32 PM, Mohammed Muneer <mmun...@ccc.com.qa> wrote:

>  Ya, but it doesn’t zoom to the margin, and fit all the four sides.****
>
> ** **
>
> ** **
>
> Regards,****
>
> Muneer,****
>
> CC….****
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> I see you already have it fit to page when printed - ****
>
> ** **
>
> Do you mean you want to have the table forced into the shape of the page
> to completely fill the page?****
>
> ** **
>
> If so, I think you will need a macro, and it could be a bit tricky.****
>
> ** **
>
> You currently have a macro adjusting the margins in the
> Worksheet.SelectionChange event -- that will slow your worksheet down --
> there is no need to reset the margins every time the cursor moves.  It
> should be enough to just set them once in the Page Setup dialog, but if you
> want to reset them with a macro, use Worksheet.Activate or
> Workbook.BeforePrint (in Workbook.BeforePrint you might check if the
> worksheet is in ActiveWindow.SelectedSheets to determine if it is one being
> printed -- if needed -- it should be reliable in most cases).****
>
> ** **
>
> To resize the table, I would use the Page Setup oftion to Fit to 1 Page
> TALL, and leave the Fit to pages wide blank.  This will only scale the
> table automatically to fit based on length, and take up as many pages wide
> as required.  Then in your macro adjust the column widths to makke it fit
> on the one page.  I am not experienced with this, so I will leave the
> details for you or others, unless I find the time to experiment with it.**
> **
>
> ** **
>
> Asa****
>
> ** **
>
> ** **
>
> *From:* excel-macros@googlegroups.com [mailto:
> excel-macros@googlegroups.com] *On Behalf Of *Mohammed Muneer
> *Sent:* Monday, May 07, 2012 11:02 PM
> *To:* excel-macros@googlegroups.com
> *Subject:* $$Excel-Macros$$ Table data fit the page size..(auto)****
>
> ** **
>
> Dear friends,****
>
> ** **
>
> I want the Table margin fit the page size – by equally grow to all the
> four sides irrespective of the data consistency.****
>
> ** **
>
> ** **
>
> ** **
>
> Regards,****
>
> Muneer,****
>
> CC…****
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com****
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com****
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to