A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

worksheet change question



 
 
Thread Tools Display Modes
  #1  
Old April 20th, 2010, 06:50 PM posted to microsoft.public.excel.misc
Tonso
external usenet poster
 
Posts: 69
Default worksheet change question

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
  #2  
Old April 20th, 2010, 07:17 PM posted to microsoft.public.excel.misc
Luke M[_4_]
external usenet poster
 
Posts: 451
Default worksheet change question

Code appears to work fine for me. Are you sure you're using the
Worksheet_SelectionChange event?

--
Best Regards,

Luke M
"Tonso" wrote in message
...
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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.