PatriceVeasey
New Member
- Joined
- Feb 16, 2016
- Messages
- 18
Hi All.
I am looking to create a script that deletes a row based on a date in a particular cell.
I have a list of dates in column F under a table heading "Start Date". The data entry's begin in row 11. What I am looking for is if the dates under this heading are older than 7 days then the VBA will delete the entire row.
I have tried a few scripts however they delete any cell that is blank in column F, therefore deleting almost my entire document. My best guess is that the script would have to include something that will look for the words "Start Date" and then search through all data below this until a blank entry. (I have posted some code below which looks for a heading "Status Average" in a different worksheet and creates a range similar to what I described, however it doesn't do what I want)
Any help would be appreciated!
Thanks in advance.
I am looking to create a script that deletes a row based on a date in a particular cell.
I have a list of dates in column F under a table heading "Start Date". The data entry's begin in row 11. What I am looking for is if the dates under this heading are older than 7 days then the VBA will delete the entire row.
I have tried a few scripts however they delete any cell that is blank in column F, therefore deleting almost my entire document. My best guess is that the script would have to include something that will look for the words "Start Date" and then search through all data below this until a blank entry. (I have posted some code below which looks for a heading "Status Average" in a different worksheet and creates a range similar to what I described, however it doesn't do what I want)
Any help would be appreciated!
Thanks in advance.
Code:
If Cells(j, 3) = "Status Average" Then
datarow_start = j + 1
Exit For
End If
Next j
If datarow_start <> 1 Then
For g = datarow_start To datarow_start + 50
If Cells(g, 3) = "" Then
On Error Resume Next
datarow_end = g - 1
Exit For
End If
Next g
Range(Cells(datarow_start, 3), Cells(datarow_end, 3)).Select