Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default When content of a cell changes, content of another deletes

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default When content of a cell changes, content of another deletes

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

" 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default When content of a cell changes, content of another deletes

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default When content of a cell changes, content of another deletes

Replace Range("B1").Delete with
Range("B1").ClearContents

Hope this helps,

Hutch

" 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default When content of a cell changes, content of another deletes

Thanks Hutch. It appears to be working just as anticipated.

Michael

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
Changing Content in one coulumn using given content in another Colin Hayes Excel Worksheet Functions 4 March 28th 10 11:28 PM
Deleting Rows - only deletes content Phil Excel Discussion (Misc queries) 2 March 12th 10 04:43 PM
cell automatically deletes content if cell is selected LD Excel Discussion (Misc queries) 0 November 1st 07 04:45 PM
copy comment content to cell content as data not as comment Lilach Excel Discussion (Misc queries) 2 June 21st 07 12:28 PM
How to transpose formulas from column content to row content. Notrom Excel Worksheet Functions 1 October 12th 06 06:57 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"