View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jason Zischke Jason Zischke is offline
external usenet poster
 
Posts: 147
Default 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