Screen aspect ratios changes when macro runs

O

owlnevada

I have files that originated with the last four versions of Excel with
Windows XP and created on different screens and resolutions. Sometimes when
I run certain macros that set a default width or row height on all the used
cells, the view comes back distorted in one dimension. Rerunning the macro
doesn't reset it and once changed after running the macros, I've not run
across a way to fix it to my standard template values. Not sure, but it seems
like it must have somethng to do with the original files which have been
updated many times.

Does anyone have any clues as to what is going on?

The code is pretty simple. Here is the one for setting the columns:

Sub FixDecreeAbstractColumnWidths(Optional control As IRibbonControl)
'
' FixColumnWidths Macro
' Resizes Abstract Column widths to standard format size

ActiveWindow.Zoom = 100
Columns("A:A").Select
Selection.ColumnWidth = 8
Columns("B:B").Select
Selection.ColumnWidth = 2
Columns("C:C").Select
Selection.ColumnWidth = 44
Columns("D:E").Select
Selection.ColumnWidth = 2
Columns("F:F").Select
Selection.ColumnWidth = 44
Columns("G:G").Select
Selection.ColumnWidth = 2
Columns("H:H").Select
Selection.ColumnWidth = 8
Columns("I:J").Select
Selection.ColumnWidth = 8
Columns("K:K").Select
Selection.ColumnWidth = 9
Columns("L:L").Select
Selection.ColumnWidth = 8
Columns("M:M").Select
Selection.ColumnWidth = 8
Columns("N:N").Select
Selection.ColumnWidth = 9
Columns("O:p").Select
Selection.ColumnWidth = 14
Columns("Q").Select
Selection.ColumnWidth = 2
Columns("R:R").Select
Selection.ColumnWidth = 36
Columns("S:S").Select
Selection.ColumnWidth = 2

ActiveWindow.Zoom = 70
Range("N2").Select

End Sub
 
B

Barb Reinhardt

I'd change it to this

Option Explicit

Sub FixDecreeAbstractColumnWidths(Optional control As IRibbonControl)
Dim aWS As Excel.Worksheet
'
' FixColumnWidths Macro
' Resizes Abstract Column widths to standard format size
Set aWS = ActiveSheet

'ActiveWindow.Zoom = 100
Application.ScreenUpdating = False
aWS.Columns("A:A").ColumnWidth = 8
aWS.Columns("B:B").ColumnWidth = 2
aWS.Columns("C:C").ColumnWidth = 44
aWS.Columns("D:E").ColumnWidth = 2
aWS.Columns("F:F").ColumnWidth = 44
aWS.Columns("G:G").ColumnWidth = 2
aWS.Columns("H:H").ColumnWidth = 8
aWS.Columns("I:J").ColumnWidth = 8
aWS.Columns("K:K").ColumnWidth = 9
aWS.Columns("L:L").ColumnWidth = 8
aWS.Columns("M:M").ColumnWidth = 8
aWS.Columns("N:N").ColumnWidth = 9
aWS.Columns("O:p").ColumnWidth = 14
aWS.Columns("Q").ColumnWidth = 2
aWS.Columns("R:R").ColumnWidth = 36
aWS.Columns("S:S").ColumnWidth = 2
Application.ScreenUpdating = True
ActiveWindow.Zoom = 70


End Sub
 
O

owlnevada

Thanks for the quick response.

I added your code and it didn't affect anything at all. The widths of cols
A to F picked up the 44 point width for some reason but cols G to V all are
unchanged or the programmed width . . . A bit puzzling. Sometimes it will
set all the widths to the same, usually the application default widths. . .
Any Clue as to why?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top