LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default How do I generate Errors for Drop-Down Lists?

Maybe use that worksheet_change event. But that doesn't give you the dropdown
to choose from.

I put a list of valid entries on Sheet99 in A1:A10 and gave it a name of MyList.

Then I rightclicked on the worksheet tab that needs this behavior and selected
view code. I pasted this in:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myRng As Range
Dim res As Variant

On Error GoTo errHandler:

'only validate changes to a single cell
If Target.Cells.Count 1 Then Exit Sub

If Intersect(Target, Me.Range("b3:b5002")) Is Nothing Then
Exit Sub
End If

Set myRng = Worksheets("sheet99").Range("a1:a10")

res = Application.Match(Target.Value, myRng, 0)

If IsError(res) Then
With Application
.EnableEvents = False
.Undo
MsgBox "Invalid entry"
End With
End If

errHandler:
Application.EnableEvents = True

End Sub





nelli wrote:

Thanks Dave.

I tried using a combobox.
I have 2 problems:

1. I would like to be able to paste valid data into the cell.
2. I want to use the sam validation for more than 5000 cells, so creating a
combobox for each of them will take up too much time.

Do you maybe have another solution to my problem?

Thanks so much for your help!


--

Dave Peterson
 
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
VLOOKUP and Multi Lists dpatte601 New Users to Excel 6 May 17th 06 10:40 AM
generate a random number and use if function to generate new data Dogdoc1142 Excel Worksheet Functions 4 April 26th 06 03:44 AM
Excel - need a function to compare lists JerryMatson Excel Worksheet Functions 1 November 24th 05 04:09 PM
How to generate a report from multiple lists in Excel 2003? Mobile PhD Excel Discussion (Misc queries) 0 July 26th 05 10:22 PM


All times are GMT +1. The time now is 01:32 PM.

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

About Us

"It's about Microsoft Excel"