PC Review


Reply
Thread Tools Rate Thread

When content of a cell changes, content of another deletes

 
 
mrlanier@hotmail.com
Guest
Posts: n/a
 
      25th Oct 2007
If a formulated value in A1 changes to any value after a value is
manually entered in B1, I need the content of B1 to be deleted. In
other words, 1) A1 first reflects a formulated value, 2) a value is
manually entered into B1, 3) input elsewhere causes A1 to return a
different calculated value, 4) thus causing B1 to delete its input.
Is there a simple macro that will accomplish this? Thanks in advance.

Michael

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIEh1dGNoaW5z?=
Guest
Posts: n/a
 
      25th Oct 2007
Paste the following code into the sheet module in the VBA Editor for the
worksheet where you want this to happen (Alt-F11 to open the VBA Editor, then
Ctrl-R to display the Project Explorer. For Sheet1, click on Sheet1, etc.)

Private LastVal

Private Sub Worksheet_Activate()
LastVal = Range("A1").Value
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$1" Then Exit Sub
If Range("A1").Value <> LastVal Then
Range("B1").Delete
LastVal = Range("A1").Value
End If
End Sub

Hope this helps,

Hutch

"(E-Mail Removed)" wrote:

> If a formulated value in A1 changes to any value after a value is
> manually entered in B1, I need the content of B1 to be deleted. In
> other words, 1) A1 first reflects a formulated value, 2) a value is
> manually entered into B1, 3) input elsewhere causes A1 to return a
> different calculated value, 4) thus causing B1 to delete its input.
> Is there a simple macro that will accomplish this? Thanks in advance.
>
> Michael
>
>

 
Reply With Quote
 
mrlanier@hotmail.com
Guest
Posts: n/a
 
      26th Oct 2007
Hutch,

Your macro works great but with one problem. There are other cells in
the same column as B1. When B1's contents delete, the cells beneath
B1 change position. For example, B10 repositions to become B9, and
then B8 with the next change to the contents of A1. They continue to
migrate one row at a time. Do you have a further suggestion? Thanks.

Michael

 
Reply With Quote
 
=?Utf-8?B?VG9tIEh1dGNoaW5z?=
Guest
Posts: n/a
 
      26th Oct 2007
Replace Range("B1").Delete with
Range("B1").ClearContents

Hope this helps,

Hutch

"(E-Mail Removed)" wrote:

> Hutch,
>
> Your macro works great but with one problem. There are other cells in
> the same column as B1. When B1's contents delete, the cells beneath
> B1 change position. For example, B10 repositions to become B9, and
> then B8 with the next change to the contents of A1. They continue to
> migrate one row at a time. Do you have a further suggestion? Thanks.
>
> Michael
>
>

 
Reply With Quote
 
mrlanier@hotmail.com
Guest
Posts: n/a
 
      26th Oct 2007
Thanks Hutch. It appears to be working just as anticipated.

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
combining content from an input box with existing cell content Colin Hayes Microsoft Excel Worksheet Functions 2 25th Jul 2010 02:30 PM
email deletes content. revmatthew Microsoft Outlook Discussion 4 29th Jun 2008 06:41 PM
cell automatically deletes content if cell is selected =?Utf-8?B?TEQ=?= Microsoft Excel Misc 0 1st Nov 2007 04:45 PM
Update query deletes content =?Utf-8?B?d2lsX3VzZ3M=?= Microsoft Access Queries 1 20th Jan 2005 01:45 AM
Highlighting cell content based on content of another cell bkarlstrom Microsoft Excel Worksheet Functions 3 4th Dec 2003 02:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:21 PM.