LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 8
Default Worksheet_Change sub routine

I am trying to understand various points of the programme listed below and
given in a book as an example (I have deleted some of the lines of code not
necessary to this question, and commented some of the lines €“ the original
had no commenting):-

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim VRange As Range, cell As Range
Dim Msg As String
Dim ValidateCode As Variant €˜returns TRUE or text string
Set VRange = Range("InputRange") €˜InputRange is defined area on spread
sheet
For Each cell In Target
If Union(cell, VRange).Address = VRange.Address Then €˜is the cell in
InputRange
ValidateCode = EntryIsValid(cell)
If ValidateCode = True Then
Exit Sub
Else
€˜This outputs message of reason not valid entry
End If
End If
Next cell
End Sub

Private Function EntryIsValid(cell) As Variant
' Returns True if cell is an integer between 1 and 12 or blank
' Otherwise it returns a string that describes the problem
€˜ i.e. entry is Text, 12 or Not an Intiger
End Function

My queries are
1. Why the line Set VRange = Range("InputRange"), why not use the
expression Range("InputRange") ?
2. Why For Each cell in Target, when sub routine gives only one
cell reference?


 
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
VB routine to print to PDF? fedude Excel Worksheet Functions 4 March 15th 08 02:04 AM
Sort Routine Platinum girl[_2_] Excel Discussion (Misc queries) 0 March 9th 07 03:21 PM
simplifying routine KneeDown2Up New Users to Excel 5 January 4th 07 05:28 PM
How to create a routine Tara Excel Discussion (Misc queries) 1 August 12th 05 02:28 AM
Solver VBA routine KLM Excel Discussion (Misc queries) 4 August 11th 05 11:51 AM


All times are GMT +1. The time now is 03:15 PM.

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"