Automtacally change entry based on value in column.

R

Richhall

Hi

I've searched the group and found 'Validation and filters with sub
scrolls' but didn't see a solution. Using Excel 2003 I have a column
with a List selection in, and a column next to it with a formula that
returns true or false (basically this determines if todays date, is a
date in another column + 30 days). If this is TRUE, i wish to set the
value to the relevant cell in the column to Expired.

I'm not sure how I do this or if it needs to be done on an Open
Worksheet event. Can anyone help please?

i.e

A B (to be hidden)
1 Status Validation
2 Open
3 Closed FALSE
4 Testing
5 Initial
6 Testing
7 Open TRUE
8 Open TRUE
9 Open FALSE
10 Open

So as soon as a value turns to TRUE then for example, row 7 and 8
should automatically become Expired.

Is this possible please?

Cheers

Rich
 
G

Gary''s Student

We can use the Calculate event:

Private Sub Worksheet_Calculate()
n = Cells(Rows.Count, "B").End(xlUp).Row
For i = 1 To n
If Cells(i, 2).Text = "TRUE" Then
Cells(i, 1).Value = "Expired"
End If
Next
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