View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Looping on Cells $x$y (continued)

Or, simpler,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Select Case True
Case (Target.Column = 1) And _
((Target.Row = 1) Or (Target.Row Mod 5 = 0))
Debug.Print "A"
Case (Target.Column = 2) And _
((Target.Row = 1) Or (Target.Row Mod 5 = 0))
Debug.Print "B"
End Select

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Chip Pearson" wrote in message
...
On further reflection, you could try something like the
following:

Select Case True
Case (Target.Column = 1) And _
(Not
(Application.IsError(Application.Match(Target.Row, Array(1, 5,
10, 15), 0))))
Debug.Print "A"
Case (Target.Column = 2) And _
(Not
(Application.IsError(Application.Match(Target.Row, Array(1, 5,
10, 15), 0))))
Debug.Print "B"
End Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"D.Parker" wrote in message
...
I was trying to eliminate extermely long lines of Case
statements.

Case "$A$1", "$A$5", "$A$10", ...."$A$n"
Do....
Case "$B$1", "$B$5", "$B$10", ...."$B$n"
Do

This would continue through column L. I thought I could be
more efficient.
Thank you for all of you assistanc.

D.Parker

"Chip Pearson" wrote:

I don't really understand your question. Could you provide a
few
more details about what you are trying to accomplish, and why
adding more Case statements won't work?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"D.Parker" wrote in
message
...
I have an worksheet with a Case structure for performing
centain
events is a
certain cell is selected:

Select Case Target.Address
Case "$B$4"
If ....Then....End If
End Select

So, now I would like to increment to, lets say to cell B5.
Is
there a way
can set up the following, unfortunately it did not work for
me
so I assumed
it was not possibe or better yet I was doing something
wrong?:

Instead of Case "$B$4" can I use Case "$i$j" to loop
through
various cells?

Thank you.

D. Parker