vba code to get an duse the value from a particular cell

T

Tonso

Using xl2003, I have the following Worksheet Selection Change code:

If Target.Column = 5 Then
Target.Columns.ColumnWidth = 27.11
ActiveWindow.Zoom = 85
Else
Columns(5).ColumnWidth = 3.78
'ActiveWindow.Zoom = 75
End If

I would like to be able to change the values zoom 85 and 75 to
correspond to the values in 2 cells, for eample, Notes!B5 and Notes!
B6, so the zoom factors can be set as needed. How can this be done?

As always,

Thanks,

Tonso
 
O

ozgrid.com

If Target.Cells.Count > 1 Then Exit Sub

If Target(1,1).Address = $B$5 Then ActiveWindow.Zoom = 85

If Target(1,1).Address = $B$6 Then ActiveWindow.Zoom = 75
 
G

Gord Dibben

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 5 Then
Target.Columns.ColumnWidth = 27.11
ActiveWindow.Zoom = Sheets("Notes").Range("B5") '85
Else
Columns(5).ColumnWidth = 3.78
ActiveWindow.Zoom = Sheets("Notes").Range("B6") '75
End If
End Sub


Gord Dibben MS Excel MVP
 
T

Tonso

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 5 Then
       Target.Columns.ColumnWidth = 27.11
       ActiveWindow.Zoom = Sheets("Notes").Range("B5")  '85
   Else
       Columns(5).ColumnWidth = 3.78
       ActiveWindow.Zoom = Sheets("Notes").Range("B6")  '75
   End If
End Sub

Gord Dibben  MS Excel MVP






- Show quoted text -

As always, Thanks so much Gord

Tonso
 

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