Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default MACRO TO CLEAR CELL CONTENTS

I have an Excel sheet on which:

1. columns B and D contain the same dates
down each column.

2. From column E and up contain data

** I am looking for a macro that will loop through
columns B and D. If it finds any row on which the
dates in B and D do not fall within the last month's
dates then
- it should clear those dates in B and D, and also
- clear all data on that row starting from Column E and
up.
- Where B and D do not contain any dates it
should do nothing.

I would appreciate your assistance very
much. Thanks.
Jay Dean
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default MACRO TO CLEAR CELL CONTENTS

Jay

Often a macro is an overkill. I use frequently other columns and a 'flag'
to determine rows to delete, eg. In a blank column, say F1)

=IF(OR(B1<NOW()-30,C1<NOW()-30),"x","")

This will put an x in the column where the dates in B1 OR C1 are less then
today - 30 days. You can the simply filter this and delete the rows.

Someone else will probably come up with a code solution, but just another
route

--
HTH
Nick Hodge
Southampton, England



"Jay Dean" wrote in message
om...
I have an Excel sheet on which:

1. columns B and D contain the same dates
down each column.

2. From column E and up contain data

** I am looking for a macro that will loop through
columns B and D. If it finds any row on which the
dates in B and D do not fall within the last month's
dates then
- it should clear those dates in B and D, and also
- clear all data on that row starting from Column E and
up.
- Where B and D do not contain any dates it
should do nothing.

I would appreciate your assistance very
much. Thanks.
Jay Dean



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default MACRO TO CLEAR CELL CONTENTS

Sub ClearOldDates()
Dim oCell As Range

For Each oCell In Range("B:B")
If IsDate(oCell) Then
If Not (Year(oCell) = Year(Now()) And Month(oCell) = Month(Now())) Then
oCell.EntireRow.Range("D1:IV1").ClearContents
oCell.ClearContents
End If
End If
Next oCell
End Sub


Jay Dean wrote
I have an Excel sheet on which:

1. columns B and D contain the same dates
down each column.

2. From column E and up contain data

** I am looking for a macro that will loop through
columns B and D. If it finds any row on which the
dates in B and D do not fall within the last month's
dates then
- it should clear those dates in B and D, and also
- clear all data on that row starting from Column E and
up.
- Where B and D do not contain any dates it
should do nothing.

I would appreciate your assistance very
much. Thanks.
Jay Dean



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
Macro to clear contents of certain cells MrAcquire Excel Discussion (Misc queries) 3 February 11th 10 05:25 PM
Macro to clear contents and put an X bevchapman Excel Discussion (Misc queries) 3 March 17th 09 07:03 PM
Macro to clear contents of unprotected cells AND drop down boxes JB2010 Excel Discussion (Misc queries) 3 March 30th 06 10:13 AM
HOW DO I PROTECT VALUES WHEN CREATING CLEAR CONTENTS MACRO? the holster Excel Discussion (Misc queries) 1 February 20th 06 06:33 PM
Clear Contents Macro SJC Excel Worksheet Functions 3 October 27th 05 07:26 PM


All times are GMT +1. The time now is 02:34 AM.

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"