ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Event Procedure not working (https://www.excelbanter.com/excel-programming/353577-event-procedure-not-working.html)

AD108

Event Procedure not working
 
I am just working on a simple data validation code, and its not working.
Any help would be appreciated. Thanks in advance

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "A:A" Then
If Len(Target) 5 Then
MsgBox "Must be 5 or less Characters"
Target.ClearContents
End If
End If
End Sub


--
Ariel Dugan
Assistant Manager
Down To Earth Natural Foods



Norman Jones

Event Procedure not working
 
Hi AD108,

Try changing:

If Target.Address = "A:A" Then

to
If Target.Column = 1 Then

However, why not use Excel's data validation rather than even code?


---
Regards,
Norman



"AD108" wrote in message
...
I am just working on a simple data validation code, and its not working.
Any help would be appreciated. Thanks in advance

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "A:A" Then
If Len(Target) 5 Then
MsgBox "Must be 5 or less Characters"
Target.ClearContents
End If
End If
End Sub


--
Ariel Dugan
Assistant Manager
Down To Earth Natural Foods





Norman Jones

Event Procedure not working
 
Hi AD108,

even code == event code

---
Regards,
Norman



AD108

Event Procedure not working
 
Thanks Norman,

I appreciate the help.

I am just trying to learn the language, I'm not actually trying to
accomplish anything.



--
Ariel Dugan
Assistant Manager
Down To Earth Natural Foods
808-947-7678 Phone
808-943-8491 Fax
808-282-5916 Cell

"Norman Jones" wrote in message
...
Hi AD108,

Try changing:

If Target.Address = "A:A" Then

to
If Target.Column = 1 Then

However, why not use Excel's data validation rather than even code?


---
Regards,
Norman



"AD108" wrote in message
...
I am just working on a simple data validation code, and its not working.
Any help would be appreciated. Thanks in advance

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "A:A" Then
If Len(Target) 5 Then
MsgBox "Must be 5 or less Characters"
Target.ClearContents
End If
End If
End Sub


--
Ariel Dugan
Assistant Manager
Down To Earth Natural Foods







Pops Jackson

Event Procedure not working
 
Norman,

I used Excel's validation and it works fine until a new row is added and the
validation moves down. My spreadsheet has a routine wich adds a new data row
at row3 for the new entry. The validation moves with the old row 3 to row 4
vwith the old data. The routine also specifies row 3 after the row addition
as follows:

Range("E3").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=transtype"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Invalid Data"
.InputMessage = ""
.ErrorMessage = "You must choose from the drop-down list."
.ShowInput = True
.ShowError = True
End With

It is not working and I am stymied as to what is wrong. Can you help?

Thanks,

Jim
--
Pops Jackson


"Norman Jones" wrote:

Hi AD108,

even code == event code

---
Regards,
Norman





All times are GMT +1. The time now is 07:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com