ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Window zoom (https://www.excelbanter.com/excel-programming/368476-excel-window-zoom.html)

Jason Zischke

Excel Window zoom
 
Hi all,

I found a bit of code that fits a certain number of columns to fit to the
excel window however my columns 'B' threw to 'E' and its only 'A' and 'F' is
meant to fit to to the rest of the window and my other difficulty is that the
zoom factor is not always 100, below is my first attempt if anyone can help
me on where I might be going wrong.

My Code

Setwidth = Worbooks("myWorkbook.xls").Sheets("Sheet1").Column s
_("B:B").Columnwidth
Setwidth = Setwidth + Worbooks("myWorkbook.xls").Sheets("Sheet1").Column s
_("C:C").Columnwidth
Setwidth = Setwidth + Worbooks("myWorkbook.xls").Sheets("Sheet1").Column s
_("D:D").Columnwidth
Setwidth = Setwidth + Worbooks("myWorkbook.xls").Sheets("Sheet1").Column s
_("E:E").Columnwidth
Totalwidth = ActiveWindow.Useablewidth
Factor = Worbooks("myWorkbook.xls").Sheets("Sheet1").Column s("B:B").width / _
Worbooks("myWorkbook.xls").Sheets("Sheet1").Column s("B:B").columnwidth _
WindowWidth = ((Totalwidth / Factor) * (((100 - ActiveWindow.Zoom) / 100) +
1)) - (Setwidth * (((100 - ActiveWindow.Zoom) / 100) + 1))
SideWidth = (WindowWidth) / 2
Workbooks("MyWorkbook.xls").Sheets("Sheet1").Colum ns("A:A").ColumnWidth = _
SideWidth
Workbooks("MyWorkbook.xls").Sheets("Sheet1").Colum ns("F:F").ColumnWidth = _
SideWidth

Thanks in Advance

Jason


All times are GMT +1. The time now is 10:07 AM.

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