+ Reply to Thread
Results 1 to 8 of 8

Data Validation On Entry

  1. #1
    Registered User
    Join Date
    10-18-2008
    Location
    Earth
    Posts
    13

    Data Validation On Entry

    My company has a very large spreadsheet with several people that add data. We want to add more data validation to the fields. I am an experienced programmer (Java, C++, etc..) but have no experience with Excel. I understand the basics of VBA, but am not too comfortable with the excel environment yet. What I would like to do is be able to run a function whenever data is entered into any row in column x. For the function I would need to know what row was edited so I can check it.

    Something like:
    Please Login or Register  to view this content.
    I just don't know how to add a hook to the worksheet to run the function when the data changes. Thanks for helping me out.
    Last edited by VBA Noob; 10-18-2008 at 02:32 PM. Reason: Added code tags as per forum rules

  2. #2
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    Hi mroctogon,

    in excel there is a event called 'Worksheet_Change(ByVal Target As Range)'.

    this will basically fire every time a value in a cell has been changed. so you could basically do the following.

    Please Login or Register  to view this content.
    this would be for any cell changed in column 24 (col x)

    altho there are built in data validation under the data>validation
    There are only 10 types of people in the world:
    Those who understand binary, and those who don't!

  3. #3
    Registered User
    Join Date
    10-18-2008
    Location
    Earth
    Posts
    13
    Thanks. Thats exactly what I need to know.
    I looked at the built in validation, but we have some pretty tricky business logic that needs to be programmed in, so that won't really help me.

  4. #4
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    yea the built in is rather basic. i always tend to use my own coded validation (so used to vb.net lol)

  5. #5
    Registered User
    Join Date
    10-18-2008
    Location
    Earth
    Posts
    13
    It looks to me like Worksheet_Change fires whenever I change a cell, but it only fires once if I copy and paste a chunk of cells in, or if I edit more than one cell at a time. Does the Target argument contain a range of some kind, or is there any other way to see that multiple cells are changed?

  6. #6
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    to get the range that has changed you can use this method of the target variable

    Please Login or Register  to view this content.
    and that will return for example $H$20:$H$30

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    You can iterate through the cells in Target:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Registered User
    Join Date
    10-18-2008
    Location
    Earth
    Posts
    13
    Thanks everybody, the cell thing got me exactly what I need.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 02-14-2008, 05:02 PM
  2. Data Validation & Lists
    By viruzman in forum Excel General
    Replies: 4
    Last Post: 02-09-2008, 01:17 PM
  3. Selecting only cells that require data entry
    By GunRights4US in forum Excel General
    Replies: 2
    Last Post: 01-03-2008, 06:27 PM
  4. Replies: 3
    Last Post: 05-12-2007, 08:12 AM
  5. Data Validation code
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2007, 06:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1