Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Missing code

I need help with the following code. The following code works except that if
the cell already has a valid value and the user types in a new valid value it
reverts back to the original value that was in the cell. It only accepts the
new valid value if the cell is blank or if the new value is picked off the
dropdown of the Data Validation / List .... dropdown list. But I need it
to also work if the user types in a new valid value over an already existing
valid value ; I want it to keep the new valid value then also.

-----------------------------------------------------------------------------------------

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo NotFound:
If ActiveCell.Column = 3 Then
With Target
.Value = Application.WorksheetFunction.VLookup( _
.Value, Range("Categories"), 1, False)
End With
End If

GoTo Found:
NotFound:
Target.Value = ""

Found:
Application.EnableEvents = True

End Sub

-------------------------------------------------------------------------------------------

Thank you for your help.

Steven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Missing code


Private Sub Worksheet_Change(ByVal Target As Range)
Dim res as Variant
On Error GoTo NotFound:
If ActiveCell.Column = 3 Then

res= Application.Match( _
Target.Value, Range("Categories"), 0)
if iserror(res) then
Application.EnableEvents = False
Target.ClearContents
end if
End if
Found:
Application.EnableEvents = True

End Sub

--
Regards,
Tom Ogilvy


"Steven" wrote in message
...
I need help with the following code. The following code works except that
if
the cell already has a valid value and the user types in a new valid value
it
reverts back to the original value that was in the cell. It only accepts
the
new valid value if the cell is blank or if the new value is picked off the
dropdown of the Data Validation / List .... dropdown list. But I need
it
to also work if the user types in a new valid value over an already
existing
valid value ; I want it to keep the new valid value then also.

-----------------------------------------------------------------------------------------

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo NotFound:
If ActiveCell.Column = 3 Then
With Target
.Value = Application.WorksheetFunction.VLookup( _
.Value, Range("Categories"), 1, False)
End With
End If

GoTo Found:
NotFound:
Target.Value = ""

Found:
Application.EnableEvents = True

End Sub

-------------------------------------------------------------------------------------------

Thank you for your help.

Steven



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Missing code

You never stop amazing me.

Thank you very much.
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
Macro - Code Missing Shane Excel Discussion (Misc queries) 4 August 4th 09 08:53 AM
Missing something in my code... Turquoise_dax[_14_] Excel Programming 3 June 23rd 06 05:57 PM
VB code gone missing Ian[_17_] Excel Programming 0 November 26th 05 11:57 AM
code to fill in missing border lines Jack Sons Excel Discussion (Misc queries) 3 November 3rd 05 10:06 PM
Missing dll to work with Ron de Bruin's code a Excel Programming 0 February 19th 05 03:49 PM


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