View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Steven Sutton Steven Sutton is offline
external usenet poster
 
Posts: 1
Default Best practice for executing code

I am rather new to programming in Excel so I am hoping someone will help me
out here. I want to execute certain subroutines depending on which cell the
user has just entered data into. Basically I want to check the user's input
for validity. From what little I know of Excel programming I am thinking of
doing something like this in the Worksheet_Change event:

Private Sub Worksheet_Change(ByVal Target as Excel.Range)

Dim t as Range
Dim r as Range
Dim i as integer

t = Target
r = Range("A:C") 'where columns A through C are the ones I want to check

i = Intersect(t,r)

Select Case i
Case 1
'insert code for if user has left Column A
Case 2
'Code for if user has left Column B
Case 3
'Code for if user has left Column C
Case Else
exit sub
End Select


Does this make sense? Is there a better way to execute code when a user
leaves a cell?

As always, I thank everyone for there time and assistance.