Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Validate Cell Content AfterUpdate

I know that the title is hardly clear but I will hope to explain what I mean.
I hope someone can help me, you have been wonderful in the past.

I want to be able to enter a value in a cell and then have it validate that
value and change the content of the cell to the appropriate text. Example:

In cell A1, I enter an "x" and when I hit enter, it changes the text to say
"Removed" or if I enter "y" or leave it blank and hit enter, it changes it to
say "N/A". This is like validation on the go type of thing. Can I write a
built-in formula and have it applied to a range of cells which will then
react the way I want when I enter data into them later?

I hope this is clear, its crystal in my head but not when it comes out in
words. Amazing how that works.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Validate Cell Content AfterUpdate

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sNew As String

If Not Intersect(Target, Range("A1")) Is Nothing Then
On Error GoTo ErrorExit
Select Case UCase(Range("A1").Text)
Case "Y", "": sNew = "N/A"
Case "X": sNew = "Removed"
End Select

If Len(sNew) Then
Application.EnableEvents = False
Range("A1") = sNew
End If
End If

ErrorExit:
Application.EnableEvents = True
End Sub

This "event" code belongs in the relavent sheet module.
Right-click sheet tab View code and paste
When all working OK close the module windows before saving

Regards,
Peter T

"Michael" wrote in message
...
I know that the title is hardly clear but I will hope to explain what I

mean.
I hope someone can help me, you have been wonderful in the past.

I want to be able to enter a value in a cell and then have it validate

that
value and change the content of the cell to the appropriate text. Example:

In cell A1, I enter an "x" and when I hit enter, it changes the text to

say
"Removed" or if I enter "y" or leave it blank and hit enter, it changes it

to
say "N/A". This is like validation on the go type of thing. Can I write a
built-in formula and have it applied to a range of cells which will then
react the way I want when I enter data into them later?

I hope this is clear, its crystal in my head but not when it comes out in
words. Amazing how that works.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Validate Cell Content AfterUpdate

Peter,

First of all, thank you so very much for taking the time to help me out.

However, I don't know if I am doing something wrong, although this is pretty
straight forward and I think I am doing it right but absolutely nothing
happens.

Nothing changes, no error even, anything I need to do that I am not doing?

Your assistance is greatly appreciated...

ps. would posting the actual setup of the sheet help you more?

"Peter T" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sNew As String

If Not Intersect(Target, Range("A1")) Is Nothing Then
On Error GoTo ErrorExit
Select Case UCase(Range("A1").Text)
Case "Y", "": sNew = "N/A"
Case "X": sNew = "Removed"
End Select

If Len(sNew) Then
Application.EnableEvents = False
Range("A1") = sNew
End If
End If

ErrorExit:
Application.EnableEvents = True
End Sub

This "event" code belongs in the relavent sheet module.
Right-click sheet tab View code and paste
When all working OK close the module windows before saving

Regards,
Peter T

"Michael" wrote in message
...
I know that the title is hardly clear but I will hope to explain what I

mean.
I hope someone can help me, you have been wonderful in the past.

I want to be able to enter a value in a cell and then have it validate

that
value and change the content of the cell to the appropriate text. Example:

In cell A1, I enter an "x" and when I hit enter, it changes the text to

say
"Removed" or if I enter "y" or leave it blank and hit enter, it changes it

to
say "N/A". This is like validation on the go type of thing. Can I write a
built-in formula and have it applied to a range of cells which will then
react the way I want when I enter data into them later?

I hope this is clear, its crystal in my head but not when it comes out in
words. Amazing how that works.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Validate Cell Content AfterUpdate

Peter,

Sorry, but after I wrote the reply I did some debugging and tinckering and
got it to work actually.

Thank you very much for your help,
I owe you one.

Michael

"Peter T" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sNew As String

If Not Intersect(Target, Range("A1")) Is Nothing Then
On Error GoTo ErrorExit
Select Case UCase(Range("A1").Text)
Case "Y", "": sNew = "N/A"
Case "X": sNew = "Removed"
End Select

If Len(sNew) Then
Application.EnableEvents = False
Range("A1") = sNew
End If
End If

ErrorExit:
Application.EnableEvents = True
End Sub

This "event" code belongs in the relavent sheet module.
Right-click sheet tab View code and paste
When all working OK close the module windows before saving

Regards,
Peter T

"Michael" wrote in message
...
I know that the title is hardly clear but I will hope to explain what I

mean.
I hope someone can help me, you have been wonderful in the past.

I want to be able to enter a value in a cell and then have it validate

that
value and change the content of the cell to the appropriate text. Example:

In cell A1, I enter an "x" and when I hit enter, it changes the text to

say
"Removed" or if I enter "y" or leave it blank and hit enter, it changes it

to
say "N/A". This is like validation on the go type of thing. Can I write a
built-in formula and have it applied to a range of cells which will then
react the way I want when I enter data into them later?

I hope this is clear, its crystal in my head but not when it comes out in
words. Amazing how that works.




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
validate a cell value Richard Excel Programming 2 July 14th 06 04:04 PM
AfterUpdate bforster1[_26_] Excel Programming 1 November 6th 04 07:16 PM
HELP! cell validate No Name Excel Programming 2 September 29th 04 07:34 PM
AfterUpdate functional equivalent at Cell level? PeteCresswell Excel Programming 2 February 27th 04 03:27 PM
Validate value in cell Mike[_40_] Excel Programming 0 August 4th 03 05:54 PM


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