Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have been able to resolve the problem by several 12 hour days of trial and error. I am posting the solution here in case some others may face a similar difficulty.
I was able to develop a worksheet change macro that functioned, but it was too large for the whole sheet, and I received a 'Procedure Too Large' error.. After some experimentation and with the assistance of two very kind men who helped me (De Primor and Deepak Barnwal) on the Excel-Macros Google Group, I stumbled on a way to split the macro. This a portion of the two macros that do the data validation, which consists of determining if there is a duplicate in a third column as a result of adding a number in the first column to a number in the second column, in case anyone on this group ever has a similar problem; Private Sub Worksheet_Change(ByVal Target As Range) Dim CurrentMessage As String CurrentMessage = ThisWorkbook.Sheets("Enter Scores").Range("AI32").Value Select Case True ' Case Not Intersect(Target, Me.Range("AG68:AG107")) Is Nothing Call CheckUsed(Target, Me.Range(Target.Address).Value, Me.Range(Target.Address).Offset(0, 1).Value, ("AI68:AI107")) Case Not Intersect(Target, Me.Range("AH68:AH107")) Is Nothing Call CheckUsed(Target, Me.Range(Target.Address).Value, Me.Range(Target.Address).Offset(0, -1).Value, ("AI68:AI107")) Case Not Intersect(Target, Me.Range("AG116:AG135")) Is Nothing Call CheckUsed(Target, Me.Range(Target.Address).Value, Me.Range(Target.Address).Offset(0, 1).Value, ("AI116:AI135")) Case Not Intersect(Target, Me.Range("AH116:AH135")) Is Nothing Call CheckUsed(Target, Me.Range(Target.Address).Value, Me.Range(Target.Address).Offset(0, -1).Value, ("AI116:AI135")) ' etc, for all of my groupings... End Select Application.EnableEvents = True End Sub ' The following sub was developed just to keep the first sub from being to large for Excel to process. I did not know there was a limit, but of course, at first I exceeded it. I believe it is somewhere around 56K when compiled. Of course, I had no idea how large it would be when compiled (and I still don't really know), but I knew I had to split it somehow because I kept getting the error messages. Again by trial and error, and with their guidance, I figured out where I could split it up with the second sub below; Private Sub CheckUsed(ByVal Target As Range, ByVal aadress As Variant, ByVal aadressoffset As Variant, ByVal Rng As String) Application.EnableEvents = False Dim CurrentMessage As String CurrentMessage = Range("AI32").Value If Application.CountIf(Range(Rng), (aadress + aadressoffset)) 1 Then If MsgBox(CurrentMessage, vbYesNo + vbQuestion, "[Personal Heading - insert your own if you copy this code]") = vbNo Then Range(Target.Address).Value = "" End Sub I still have not figured out why Excel's built-in data validation is not consistent in giving me a valid result with either validation forumla '=if(Countif($C$1:$C$20,$A1+$B1)<=1,"True","False" )' or 'Countif($C$1:$C:20,)$A1+$B1))<=1' - I don't know if both of my attempts at a validation formula were not correct or what the problem was. My problem started when Excel 2007 came out - prior to that they seemed to work fine. After Excel 2007, sometimes one of these works at detecting a duplicate, sometimes neither one works at detecting a duplicate, and sometimes I get a nuisance error message when there was no duplicate. Going to VBA for my data validation has eliminated the problem, as far as I can tell anyway. If someone knows why neither of these formulas worked reliably in Excel2007 and later, I would appreciate knowing to increase my understanding of Excel. But for now, my problem has been solved. Best wishes to all on the group. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using Table Column for Data Validation List | Excel Discussion (Misc queries) | |||
Data Validation - lists if certain column is certain value | Excel Programming | |||
Dependant Data Validation - for Whole Column | Excel Worksheet Functions | |||
Loading Column Data with blank Rows into Data Validation Box | Excel Worksheet Functions | |||
Multi column Data Validation List | Excel Programming |