Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Extending sub to cover other target cells

How could the sub below* be extended to cover additional cells besides C2,
viz.: the zoom to 120 should work for: C2, C25, C48, C71, C94
(the other cells in col C are offset to the start cell C2 by 24)
*from Debra's site

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$C$2" Then
ActiveWindow.Zoom = 120
Else
ActiveWindow.Zoom = 100
End If
End Sub

Thanks
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--


  #2   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Extending sub to cover other target cells

Oops, line
(the other cells in col C are offset to the start cell C2 by 24)


should read:
(the other cells in col C are offset to the start cell C2 by steps of 24)


--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default Extending sub to cover other target cells

Instead of
If Target.Address = "$C$2" Then
use
If ((Target.Column = 3) And ((Target.Row Mod 23) = 2)) Then
(This uses steps of 23 per the cell addresses listed; if you need the last
matching cell to be C94, you could further qualify it with "And (Target.Row
<= 94)" ).

"Max" wrote:

How could the sub below* be extended to cover additional cells besides C2,
viz.: the zoom to 120 should work for: C2, C25, C48, C71, C94
(the other cells in col C are offset to the start cell C2 by 24)
*from Debra's site

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$C$2" Then
ActiveWindow.Zoom = 120
Else
ActiveWindow.Zoom = 100
End If
End Sub

Thanks
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--



  #4   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Extending sub to cover other target cells

Thanks, bpeltzer !
That works great.
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--
"bpeltzer" wrote in message
...
Instead of
If Target.Address = "$C$2" Then
use
If ((Target.Column = 3) And ((Target.Row Mod 23) = 2)) Then
(This uses steps of 23 per the cell addresses listed; if you need the

last
matching cell to be C94, you could further qualify it with "And

(Target.Row
<= 94)" ).



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Extending sub to cover other target cells

I like:

if target.cells.count 1 then exit sub 'one cell at a time
if intersect(target, me.range("c2,c25,c48,c71,c94")) is nothing then
exit sub
end if

Especially when there doesn't seem to be a pattern.

Max wrote:

How could the sub below* be extended to cover additional cells besides C2,
viz.: the zoom to 120 should work for: C2, C25, C48, C71, C94
(the other cells in col C are offset to the start cell C2 by 24)
*from Debra's site

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$C$2" Then
ActiveWindow.Zoom = 120
Else
ActiveWindow.Zoom = 100
End If
End Sub

Thanks
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How many cells can a correlation function cover? Correl Excel Discussion (Misc queries) 2 June 14th 10 01:38 PM
Data entered needs to cover 2 vertical cells The Little Mermaid Excel Discussion (Misc queries) 7 September 3rd 07 11:34 AM
Target cell reference moves when target is cut and pasted Illya Teideman Excel Discussion (Misc queries) 5 May 31st 07 11:34 AM
Help - loop through cells in a range that are not together (several different cells as Target) Marie J-son[_5_] Excel Programming 4 April 3rd 05 09:54 PM
How find if target is object in Worksheet_Change (ByVal Target As.. ?) Gunnar Johansson Excel Programming 3 July 1st 04 09:25 PM


All times are GMT +1. The time now is 12:41 AM.

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

About Us

"It's about Microsoft Excel"