From: Tonso on 20 Apr 2010 13:50 As I scroll across a particular spreadsheet, I would like to have the following columns change width, and zoom, as shown in the code below. However, the results are erractic. The zoom only works on the last column, and all the widths are 20. How do I correct this situation so each column behaves as I want? Thanks, Tonso If Target.Column = 7 Then Target.Columns.ColumnWidth = 20 ActiveWindow.Zoom = Sheets("Notes").Range("c28") 'c28 = 100 Else Columns(7).ColumnWidth = 3.33 ActiveWindow.Zoom = Sheets("Notes").Range("c27") 'c27 = 80 End If If Target.Column = 8 Then Target.Columns.ColumnWidth = 34 ActiveWindow.Zoom = Sheets("Notes").Range("c28") Else Columns(8).ColumnWidth = 3.33 'ActiveWindow.Zoom = Sheets("Notes").Range("c27") End If If Target.Column = 9 Then Target.Columns.ColumnWidth = 20 ActiveWindow.Zoom = Sheets("Notes").Range("c28") Else Columns(9).ColumnWidth = 3.33 'ActiveWindow.Zoom = Sheets("Notes").Range("c27") End If If Target.Column = 10 Then Target.Columns.ColumnWidth = 27 ActiveWindow.Zoom = Sheets("Notes").Range("c28") Else Columns(10).ColumnWidth = 3.33 'ActiveWindow.Zoom = Sheets("Notes").Range("c27") End If
From: Luke M on 20 Apr 2010 14:17 Code appears to work fine for me. Are you sure you're using the Worksheet_SelectionChange event? -- Best Regards, Luke M "Tonso" <wthomasss(a)hotmail.com> wrote in message news:df6e91ad-308c-4b8f-8aff-b67175f12cce(a)g1g2000pre.googlegroups.com... > As I scroll across a particular spreadsheet, I would like to have the > following columns change width, and zoom, as shown in the code below. > However, the results are erractic. The zoom only works on the last > column, and all the widths are 20. How do I correct this situation so > each column behaves as I want? > > Thanks, > > Tonso > > If Target.Column = 7 Then > Target.Columns.ColumnWidth = 20 > ActiveWindow.Zoom = Sheets("Notes").Range("c28") 'c28 = 100 > Else > Columns(7).ColumnWidth = 3.33 > ActiveWindow.Zoom = Sheets("Notes").Range("c27") 'c27 = 80 > End If > If Target.Column = 8 Then > Target.Columns.ColumnWidth = 34 > ActiveWindow.Zoom = Sheets("Notes").Range("c28") > Else > Columns(8).ColumnWidth = 3.33 > 'ActiveWindow.Zoom = Sheets("Notes").Range("c27") > End If > If Target.Column = 9 Then > Target.Columns.ColumnWidth = 20 > ActiveWindow.Zoom = Sheets("Notes").Range("c28") > Else > Columns(9).ColumnWidth = 3.33 > 'ActiveWindow.Zoom = Sheets("Notes").Range("c27") > End If > If Target.Column = 10 Then > Target.Columns.ColumnWidth = 27 > ActiveWindow.Zoom = Sheets("Notes").Range("c28") > Else > Columns(10).ColumnWidth = 3.33 > 'ActiveWindow.Zoom = Sheets("Notes").Range("c27") > End If
|
Pages: 1 Prev: Options saved with the worksheet? Next: Cell colour in relation to IF results |