I see my name but I have no memory of writing that! Must be a *senior
moment* <g>
I think that the ambiguous name error will be because when you entered the
sheet module XL put the bare bones of a Worksheet_SelectionChange in for
you then you pasted my macro giving you two macros of the same name. Delete
everything in the module and paste in this one:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Intersect(Target, Range("A:C")) Is Nothing Then Exit Sub
On Error GoTo GetOut
Application.EnableEvents = False
a = Application.CountA(Range("A1:A40"))
b = Application.CountA(Range("B1:B40"))
c = Application.CountA(Range("C1:C40"))
If a = b And a <> c Then
Cells(Cells(100, 1).End(xlUp).Row, 3).Select
MsgBox "Please fill in all three cells first"
End If
GetOut:
Application.EnableEvents = True
End Sub
I see in the original macro for some reason looks for data from row 12 to
100. I don't see you asking for this anywhere so I have re-written it to
look at the data in A3:C40 if that is not right then change the lines
a = Application.CountA(Range("A3:A40"))
b = Application.CountA(Range("B3:B40"))
c = Application.CountA(Range("C3:C40"))
or to whatever you data start line is in.
To ensure that they enter 4 digits select C3:C40 then select:
Data > Validation > Settings > in the Allow: box select Custom then in the
Formula: box that will appear enter the formula:
=AND(ISNUMBER(A3),LEN(A3)=4)
But either do that *before* you put the macro in or open the Workbook with
Macros disabled.
You can also add Input and Error messages.
Post back if you are still having difficulties.
--
HTH
Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings
(E-Mail Removed)
Replace @mailinator.com with @tiscali.co.uk
"Alchemist" <(E-Mail Removed)> wrote in message
news:51143BDA-9C9B-4D1C-B74D-(E-Mail Removed)...
> Hi Sandy.
>
> I tried below without changes and immediantly I got an error:
> VB Compile Error
> Ambiguous name detected: Worksheet_SelectionChange
>
> and the first line is highlighted
> Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range
>
> What does this mean?
>
> And just to make sure, column E(row 3) requires 4digits to be entered if
> column C (row3) has data in it and down the page to row 40, this will
> work?
>
> Thanks.
>
>