Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Why the DataValidation Code not working?

Hi All,

to my pre question I got the following code:

What I intend to do is in my sheet2 range A1,a1.end
(xldown) is named as "MemberList" and in my sheet1 B2 i
have a data validation type List(Memberlist)

if i type in sheet1 A2 the first few letters the data
validation in B2 should list only names starting those
typed letters in A2 since my list is so long browsing
down and selecting makes this way easy.

all my "MemberList" data are in Ucase

any idea why the following code do not work?


Private Sub Worksheet_Change(ByVal Target As Range)
Dim cInput As Long, cValues As Long
Dim i As Long, j As Long
Dim vValue
Const dvCell As String = "$B$2"
Const selectCell As String = "$A$2"
Const listSheet As String = "Sheet2"

Application.EnableEvents = False
If Target.Address = selectCell Then
Worksheets("Sheet2").Columns(3).ClearContents
cInput = Len(Target.Value)
cValues = Worksheets(listSheet).Range
("MemberList").Cells(Rows.Count, _
1).End(xlUp).Row
j = 1
For i = 1 To cValues
vValue = Worksheets(listSheet).Range
("MemberList").Cells(i, _
1).Value
If UCase(Left(vValue, cInput)) = UCase
(Target.Value) Then
Worksheets(listSheet).Cells(j, "C").Value
= vValue
j = j + 1
End If
Next i
End If

If j 1 Then
ThisWorkbook.Names.Add Name:="shortRange",
RefersTo:="=" & listSheet _
& "!$C$1:$C$" & j - 1
With Range(dvCell).Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _
Formula1:="=shortRange"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range(dvCell).Value = Worksheets(listSheet).Range
("N1").Value
Range(dvCell).Select
End If

Application.EnableEvents = True

End Sub


TIA
Soniya
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filtering or Formatting DataValidation List Lost Cluster Excel Discussion (Misc queries) 6 June 5th 10 10:47 PM
DataValidation Check in cell of excel AmitAgarwal Excel Discussion (Misc queries) 3 July 20th 09 03:29 PM
datavalidation conditional list TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 March 28th 07 02:45 AM
datavalidation conditional list Toppers Excel Discussion (Misc queries) 1 March 28th 07 02:08 AM
Code not working Bob Phillips[_5_] Excel Programming 5 August 14th 03 03:12 PM


All times are GMT +1. The time now is 09:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"