Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 17
Default emptying the contets of a cell base on the value of another cell

I am trying to empty a cells content based on the value of another cell.
Example: if cell A1 is "X" and cell B1 is "X" , and the contents in cell A1
is changed to "Y" then I want cell B1 to be emptied.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 17
Default emptying the contets of a cell base on the value of another cell

I need to further add that cell B1 is a cell that the user can enter data into

"tracktor" wrote:

I am trying to empty a cells content based on the value of another cell.
Example: if cell A1 is "X" and cell B1 is "X" , and the contents in cell A1
is changed to "Y" then I want cell B1 to be emptied.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default emptying the contets of a cell base on the value of another cell

Then you will need to use VBA event code. Right-click the tab for worksheet
where you want this functionality to occur on and select View Code from the
popup menu that appears; then copy/paste the following into the code window
that appeared...

'********************** START OF CODE **********************
Dim PreviousValue As String

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
If Range("A1").Value = "Y" And Range("B1").Value = "X" And _
PreviousValue = "X" Then Range("B1").Value = ""
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then PreviousValue = Target.Value
End Sub
'*********************** END OF CODE ***********************

This code will react in **exactly** the way you asked for it to react. My
gut feeling is you really want something slightly different than this, but
if that is the case, you will have to provide a more detailed description.

Rick


"tracktor" wrote in message
...
I need to further add that cell B1 is a cell that the user can enter data
into

"tracktor" wrote:

I am trying to empty a cells content based on the value of another cell.
Example: if cell A1 is "X" and cell B1 is "X" , and the contents in cell
A1
is changed to "Y" then I want cell B1 to be emptied.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 17
Default emptying the contets of a cell base on the value of another ce

Rick,

Thanks, that did it.

"Rick Rothstein (MVP - VB)" wrote:

Then you will need to use VBA event code. Right-click the tab for worksheet
where you want this functionality to occur on and select View Code from the
popup menu that appears; then copy/paste the following into the code window
that appeared...

'********************** START OF CODE **********************
Dim PreviousValue As String

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
If Range("A1").Value = "Y" And Range("B1").Value = "X" And _
PreviousValue = "X" Then Range("B1").Value = ""
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then PreviousValue = Target.Value
End Sub
'*********************** END OF CODE ***********************

This code will react in **exactly** the way you asked for it to react. My
gut feeling is you really want something slightly different than this, but
if that is the case, you will have to provide a more detailed description.

Rick


"tracktor" wrote in message
...
I need to further add that cell B1 is a cell that the user can enter data
into

"tracktor" wrote:

I am trying to empty a cells content based on the value of another cell.
Example: if cell A1 is "X" and cell B1 is "X" , and the contents in cell
A1
is changed to "Y" then I want cell B1 to be emptied.



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
Define a cell value base on the date BaseballFan Excel Discussion (Misc queries) 2 April 10th 07 01:51 AM
Hiding row base on cell content brownti via OfficeKB.com Excel Discussion (Misc queries) 11 February 14th 07 06:53 PM
how to show different photos, base on different value of a cell? Howard Hsu Excel Worksheet Functions 2 January 25th 06 06:57 PM
unique values in a cell base on another cell Jay Excel Discussion (Misc queries) 2 November 18th 05 06:46 PM
Sumif and base it on font color of cell Bruce Excel Worksheet Functions 1 September 28th 05 10:52 PM


All times are GMT +1. The time now is 02:54 AM.

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"