LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Help! Stop Users from corrupting Drop Down Box Macro

Note - current code is at the bottom of this question. I'm not sure, but
think this is called a worksheet event?

In columns C and D of several sheets in a template, I have drop down boxes
for selecting Type and Owner. If the user selects a Type Name, a Type
Abbreviation is returned (from a hidden "Code" sheet), ie; select Apple,
template shows AP, select Jack Web, template returns JW. The Type and Owner
drop downs are adjacent, in Columns C and D, but are not in every row
because of subtotals and blank rows.

My problem - users sometimes key in "AP" instead of selecting
"Apple", or copy/paste "AP" from another row. These actions are causing
errors.

Is there a way to either revise the following code so that copy/paste or
keying in an "AP" gives the same result
as selecting Apple from the Drop Down? Or alternately, not allow the user to
do anything but select - with a message if they attempt - that they need to
select from the drop down options? Here is my
current code - on right click of the worksheet tab/show code /
.........................
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count 1 Then GoTo exitHandler

If Target.Column = 3 Then
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Target.Value = Worksheets("Codes").Range("a1") _
.Offset(Application.WorksheetFunction _
.Match(Target.Value, Worksheets("Codes").Range("ExpType"), 0), 0)
End If
Application.EnableEvents = True

If Target.Cells.Count 1 Then GoTo exitHandler

If Target.Column = 4 Then
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Target.Value = Worksheets("Codes").Range("d1") _
.Offset(Application.WorksheetFunction _
.Match(Target.Value, Worksheets("Codes").Range("ExpOwner"), 0), 0)

End If
exitHandler:
Application.EnableEvents = True
Exit Sub

errHandler:
If Err.Number = 13 Or Err.Number = 1004 Then
GoTo exitHandler
Else
Resume Next
End If

End Sub
 
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
Excel file opens Read-Only for different users...stop! Pradhan Excel Discussion (Misc queries) 1 November 3rd 08 06:12 PM
Stop users pasting data in cells trainerab Excel Discussion (Misc queries) 2 February 5th 08 05:37 PM
Formatting unlocked cells and stop users from pasting [email protected] Excel Programming 4 October 26th 07 01:55 PM
Stop users from inserting new lines and columns? KuroNeko Excel Programming 4 June 25th 07 04:44 PM
stop users from deleting rows wAyne Excel Discussion (Misc queries) 2 February 4th 06 05:57 PM


All times are GMT +1. The time now is 02:01 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"