# Clear contents based on contents of another cell

1. ## Clear contents based on contents of another cell

I've searched the board and found solutions to similar issues, but nothing that addresses the problem I'm working on. I'm using Excel 2010.

Column H contains an opening date. Column I contains ages calculated via formula (e.g., I4 contains "=TODAY()-H3"). Column J may or may not contain a date. If Column J contains a date, Column L should display a closure age calculated by subtracting the date in Column H from the date in Column J.

I need a macro that generates the following results, and I'm coming up dry:

If the cell Column J is empty, the cell in Column I should display an age and the cell column L should be empty. If a date is entered into the cell in Column J, the cell in Column I should be empty and the cell in Column L should display a closure age. I need this to apply to all cells in these columns between Row 3 and Row Infinity.

Thank you for your assistance; this is my first dive into VBA and macros.

2. ## Re: Clear contents based on contents of another cell

You should be able to do this with a formula. Something like this in column L =IF(J3="","",whatever your formula or value is). Column I =IF(J3="", whatever the formula or value, "")

Then fill down

3. ## Re: Clear contents based on contents of another cell

Why dont you directly put formulae into the cells? Why do you need a macro for this?

4. ## Re: Clear contents based on contents of another cell

If it's the case the formulae are the more efficient solution, then I'm having difficulty finding the correct formulae and formatting them properly.

Hi

Try this

6. ## Re: Clear contents based on contents of another cell

Originally Posted by mehmetcik
Hi

Try this
That was incredibly helpful and exactly what I needed. Thank you!

7. ## Re: Clear contents based on contents of another cell

Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

In future, to mark your thread as Solved, you can do the following -

Incase your issue is not solved, you can undo it as follows -

Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1