Wikiposts
Search
Computer/Internet Issues & Troubleshooting Anyone with questions about the terribly complex world of computers or the internet should try here. NOT FOR REPORTING ISSUES WITH PPRuNe FORUMS! Please use the subforum "PPRuNe Problems or Queries."

Excel data validation macro

Thread Tools
 
Search this Thread
 
Old 30th Jul 2007, 10:55
  #1 (permalink)  
Thread Starter
 
Join Date: Jun 2006
Location: London
Posts: 10
Likes: 0
Received 0 Likes on 0 Posts
Excel data validation macro

Any Excel experts out there?
I've been asked to look at the feasibility of running a macro in Excel that will check entered (mostly cut/pasted) data against a table of valid values.
I've googled 'data validation' etc but this seems to mostly bring back references to drop down lists as data is manually entered into a cell.
The data to be check could be upto 31 columns wide, by any number of lines( 000's or 0000's maybe). I have seen something similar in SQL statements, where a piece of data can be checked to see if it exists in another table....is there something like this available in Excel VB?
Any advice gratefully received!
TessCoes is offline  
Old 30th Jul 2007, 11:23
  #2 (permalink)  
bnt
 
Join Date: Feb 2007
Location: Dublin, Ireland. (No, I just live here.)
Posts: 733
Received 6 Likes on 5 Posts
You don't say what kind of data it is, but if it's simple string or numeric data, a Macro is overkill, in my opinion.

If the data is in Table form, and can be viewed as a list of 1-line "Records", then you have some good tools at your disposal. Just sorting the table on the relevant column can send all "out of range" values to the top and/or bottom, where you can easily see them. There's also the "Data Filter" menu option , where you can show or hide records by the values in columns, even "show only blanks" to highlight missing data.

For more unstructured data, you have the Conditional Formatting feature. Data matching the rule can be made to appear in a larger font, in red, etc., so you can spot it immediately. If it's a lot of data, view it at 10% Zoom. The good values are just dots, but you can make any invalid values stand out like the proverbial sore thumb.
bnt is offline  
Old 30th Jul 2007, 12:02
  #3 (permalink)  
bnt
 
Join Date: Feb 2007
Location: Dublin, Ireland. (No, I just live here.)
Posts: 733
Received 6 Likes on 5 Posts
Lastly: it sounds like you have a list of "valid" data in a table. In that case, you may want to investigate the COUNTIF functions. I imagine a scenario like this:
- you have the pasted data on Sheet 1 of the Workbook
- you have the table of valid data on Sheet 2, cells A1..A10)
- On Sheet 3, set up the first test formula "under" the data on Sheet 1. (If the first value is in Cell A1 of Sheet 1 (Sheet1!A1), then put the test formula in Sheet3!A1.

The formula would do a "count" of the valid values, from the table, so a result of Zero means that the data is not in the table (invalid). I just did a quick test: with valid data in Sheet2 cells A1..A10, the formula in Sheet3!A1 is =COUNTIF(Sheet2!$A$1:$A$10,Sheet1!A1)

Note the $ signs are necessary to "lock" the references to the fixed table of valid data. This means that you can copy the formula to match the size of the table in Sheet 1: Sheet1!A1 becomes Sheet1!A2 and so on, but the valid data table stays in one place.
bnt is offline  
Old 30th Jul 2007, 12:06
  #4 (permalink)  
Thread Starter
 
Join Date: Jun 2006
Location: London
Posts: 10
Likes: 0
Received 0 Likes on 0 Posts
Thanks bnt, sadly it's a lot more complicated.
Data in each column would be either numbers or text...sometimes both!
To clarify...any given cell in this spreadsheet may be populated with numbers (or text, or both!!), but not just any number or text...they have to be valid when compared to a list of values....simple ranges won't work ie, we may use 102000 & 103000 but nothing between, (or indeed ABC & XYZ but not STU).
There's too many valid values and cells to provide drop downs for each one....and in most cases the data would pasted in, not entered manually.
What I have is a file that contains the defined valid values available for each column in the s/sheet....can I get excel to compare the values that are entered/pasted in the s/sheet against this file somehow...similar to v/h lookups...but in the background...via macro?
I may be asking the impossible I guess!

bnt, just seen your 13:02...sounds interesting...will have a play

Last edited by TessCoes; 30th Jul 2007 at 12:50.
TessCoes is offline  
Old 30th Jul 2007, 13:46
  #5 (permalink)  
bnt
 
Join Date: Feb 2007
Location: Dublin, Ireland. (No, I just live here.)
Posts: 733
Received 6 Likes on 5 Posts
If you can do it without Macros, then all the better, I think. I use Macros myself, but it is basically programming, with all that implies: if you're not careful, a Macro can misbehave, overwrite things unexpectedly. It needs "care and feeding", you might say.
bnt is offline  

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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



Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service

Copyright © 2024 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.