View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Increment and replace a cell value

The following event macro monitors A1 thru A10. If any of the cells in this
range becomes "Yes", then that cell is cleared and the adjacent cell in
column B is incremented by 14

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
If Intersect(t, Range("A1:A10")) Is Nothing Then Exit Sub
If t.Value < "Yes" Then Exit Sub
Application.EnableEvents = False
t.Value = ""
t.Offset(0, 1).Value = t.Offset(0, 1).Value + 14
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200909


"Doc77" wrote:

I am trying to get a cell (B1) -- a date -- to increment by 14 if cell (A1)
="Yes".

The bigger picture is that I have many tasks that require status updates. I
want to use column A to reference another worksheet to determine if an update
has been received. If the update has been received then A(x) will become a
"Yes". If A(x) is "Yes" the Due Date in cell B(x) will increase by 14-days
and return that date value.

Ideally, I would like the equation for B(x) to increment by 14 and cause
A(x) to be returned to "".

Is this possible in Excel 2003???

Thanks!!