Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use "Data Validation" after data are entered
Hello,
I have two xls files: file1.xls and file2.xls 1. File1.xls has been filled by a user via a data base thanks to VB.NET code. At that level, let's suppose he doesn't know our specific constraints. 2. Each column of file2.xls is associated with "Data Validation" constraints. I would like to use "Data Validation" of file2.xls to check file1.xls Is it possible to check by program (via VB code ) if the content of cell "A1" of file1.xls is OK according "Data Validation" defined in the cell "A1" of file2.xls (after file1.xls has been fully filled)? Thank you |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use "Data Validation" after data are entered
Phillippe,
It would be a whole lot easier to do the validation solely through VBA. To start, you would need to know each column's validation requirements. Then you could use code like this to flag the bad cells with red backgrounds: Sub TryNow() Dim myCell As Range Dim myCol As Range Cells.Interior.ColorIndex = xlNone For Each myCol In ActiveSheet.UsedRange.Columns If myCol.Column = 1 Then For Each myCell In myCol.Cells 'This is the data validation for column A If myCell.Value 100 Or myCell.Value < 0 Then myCell.Interior.ColorIndex = 3 End If Next myCell End If If myCol.Column = 2 Then For Each myCell In myCol.Cells 'This is the validation for column B If myCell.Value 120 Or myCell.Value < -10 Then myCell.Interior.ColorIndex = 3 End If Next myCell End If Next myCol End Sub HTH, Bernie MS Excel MVP "Philippe TEIRUH" wrote in message ... Hello, I have two xls files: file1.xls and file2.xls 1. File1.xls has been filled by a user via a data base thanks to VB.NET code. At that level, let's suppose he doesn't know our specific constraints. 2. Each column of file2.xls is associated with "Data Validation" constraints. I would like to use "Data Validation" of file2.xls to check file1.xls Is it possible to check by program (via VB code ) if the content of cell "A1" of file1.xls is OK according "Data Validation" defined in the cell "A1" of file2.xls (after file1.xls has been fully filled)? Thank you |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
need to build a "form" that dumps data entered into another worksh | Excel Discussion (Misc queries) | |||
Calculation Using "Most Current Data Entered" | Excel Worksheet Functions | |||
Data Validation - List - Data "NOT BETWEEN" - Source Possible? | Excel Worksheet Functions | |||
How can "data validation" be enforced in calculated cells | Excel Worksheet Functions | |||
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc | Excel Programming |