Increment and replace a cell value

D

Doc77

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!!
 
G

Gary''s Student

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top