PC Review


Reply
Thread Tools Rate Thread

Delete the contents of a cell if (REVISED)

 
 
mrlanier@hotmail.com
Guest
Posts: n/a
 
      23rd Jan 2007
If have simplified a problem I stated earlier:

If B1=1, delete the contents of A1. If B1 changes to any other value,
I do not want the former contents of A1 to return. Instead, I want to
be able to manually enter new contents, knowing that as often as B1
returns to equal 1, anything in A1 will be deleted. As I admit to my
novice status, the simpler the solution, the better. Thanks.

Michael

 
Reply With Quote
 
 
 
 
merjet
Guest
Posts: n/a
 
      23rd Jan 2007
Add to worksheet module:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$1" And Target.Value = 1 Then Range("A1") =
""
'if A1 is changed and already B1=1, then A1 won't be deleted.
'you may want to enable the following line.
'If Target.Address = "$A$1" Then Range("B1") = ""
End Sub

Hth,
Merjet

 
Reply With Quote
 
mrlanier@hotmail.com
Guest
Posts: n/a
 
      23rd Jan 2007
Thanks Gary's Student and merjet for your suggestions. I'll be trying
both shortly and let you know shortly.

Michael

 
Reply With Quote
 
mrlanier@hotmail.com
Guest
Posts: n/a
 
      23rd Jan 2007
Gary's Student,

I have encountered 2 problems:

First, B1 has to equal something, so instead of nothing, can we
reformulate to make B1=0?

Second, I'm getting the message "Ambiguous name detected:
Worksheet_Change". does this have anything to do with the fact that
I have a different macro on the same worksheet labeled "Private Sub
Worksheet_Change(ByVal TargetCell As Range)", which is slightly
different from yours (you don't have "Cell" shown?

Michael

 
Reply With Quote
 
mrlanier@hotmail.com
Guest
Posts: n/a
 
      23rd Jan 2007
Gary's Student,

I have encountered 2 problems:

First, B1 has to equal something, so instead of nothing, can we
reformulate to make B1=0?

Second, I'm getting the message "Ambiguous name detected:
Worksheet_Change". does this have anything to do with the fact that
I have a different macro on the same worksheet labeled "Private Sub
Worksheet_Change(ByVal TargetCell As Range)", which is slightly
different from yours (you don't have "Cell" shown?

Michael

 
Reply With Quote
 
merjet
Guest
Posts: n/a
 
      23rd Jan 2007
> First, B1 has to equal something, so instead of nothing, can we
> reformulate to make B1=0?


Yes, e.g.:
If Target.Address = "$A$1" Then Range("B1") = 0

> Second, I'm getting the message "Ambiguous name detected:
> Worksheet_Change". does this have anything to do with the fact that
> I have a different macro on the same worksheet labeled "Private Sub
> Worksheet_Change(ByVal TargetCell As Range)", which is slightly
> different from yours (you don't have "Cell" shown?


Yes. You need to combine them, which is probably not a problem if
they have different "if conditions". Repace "TargetCell" with "Target"
in code before or after combining.

Hth,
Merjet

 
Reply With Quote
 
mrlanier@hotmail.com
Guest
Posts: n/a
 
      23rd Jan 2007

Thanks merjet,

Unfortunately, when I make the suggested change, other existing
conditional macros no longer work. Thanks for trying, but this seems
to be beyond me for the time being.

Michael

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      23rd Jan 2007
Post ALL of your code here for comments and suggestions.

--
Don Guillett
SalesAid Software
(E-Mail Removed)
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Thanks merjet,
>
> Unfortunately, when I make the suggested change, other existing
> conditional macros no longer work. Thanks for trying, but this seems
> to be beyond me for the time being.
>
> Michael
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete contents of cell RDC Microsoft Excel Misc 1 21st Jan 2009 04:13 PM
Delete cell contents Rob Microsoft Excel Misc 7 10th Apr 2007 12:34 PM
Delete Cell Contents IF joecrabtree Microsoft Excel Programming 3 18th Dec 2006 02:21 PM
Delete row based on contents of cell =?Utf-8?B?QW5keUc=?= Microsoft Excel Misc 6 17th Nov 2005 10:08 PM
Delete cell contents with input to adjacent cell Ashley Frank Microsoft Excel Misc 1 5th Oct 2005 04:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:20 PM.