Hi Everybody. First time poster here. I'm new to prgramming in general and have only been doing VBA work for a couple of weeks. So please feel free to ask for clarification. I only ask that you use "little words" that I can understand.
I am trying to set up a few lines of code that will delete a line if the date in one column is less than 6 months from today's date. Here is what I have:
Dim i2 As Integer
i2 = 1
Dim x As Integer
Dim today As Integer
Dim SLED As Integer
Do While Cells(i + 1, 1) <> ""
x = DateValue(Cells(i + 1, 18))
today = DateValue(Date)
SLED = 183
If (x - Date) < SLED Then
Cells(i + 1, 18).EntireRow.Delete
Else
i = i + 1
End If
Loop
It is a slightly modified version of a code I used to remove a line if a different column was below a certain value. That one works like a charm, but this one doesn't. It doesn't throw up an error, but it just kind of doesn't do what I need it to. After it runs, I see dates from July still in the data set. I've tried to tweak a few different things, so I may have a few diffferent problems in there.
Thanks!
I am trying to set up a few lines of code that will delete a line if the date in one column is less than 6 months from today's date. Here is what I have:
Dim i2 As Integer
i2 = 1
Dim x As Integer
Dim today As Integer
Dim SLED As Integer
Do While Cells(i + 1, 1) <> ""
x = DateValue(Cells(i + 1, 18))
today = DateValue(Date)
SLED = 183
If (x - Date) < SLED Then
Cells(i + 1, 18).EntireRow.Delete
Else
i = i + 1
End If
Loop
It is a slightly modified version of a code I used to remove a line if a different column was below a certain value. That one works like a charm, but this one doesn't. It doesn't throw up an error, but it just kind of doesn't do what I need it to. After it runs, I see dates from July still in the data set. I've tried to tweak a few different things, so I may have a few diffferent problems in there.
Thanks!