Verify date by week.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Okay I import a txt file that has data by week, but if the week has no
entries it's not there so I need to add that week to the file so I can copy
it over into another
worksheet. I can't seem to get the right combination of syntax/formula
correct.

There should always be data in 12/29/07 row.

This is what I started out with.
For a = 53 to 2 step -1
Range("A"+Cstr(a)+"").activate
DateCurr = activecell.value
DatePrev = activecell.offset(-1,0).value
If DateCurr <> DatePrev + 7 then
selection.entirerow.insert
Range("A"+Cstr(a)+"").value = DateCurr + 7
Next a

Do I have to do something with date() function to make this work or do I
force column a format to date?
 
Try this:

I'd do it with a copy of your workbook to ensure it gives you what you want.

Sub Macro1()
Dim myRange As Range

For a = 3 To 54
Set myRange = Range("A" & a)
If myRange.Value <> myRange.Offset(-1, 0).Value + 7 Then
Debug.Print myRange.Address, myRange.Value, myRange.Offset(-1, 0).Value
Debug.Print
myRange.EntireRow.Insert
Debug.Print myRange.Address
myRange.Offset(-1, 0).Value = myRange.Offset(-2, 0) + 7

End If
Next a

End Sub
 

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

Similar Threads

Column and row advance 1
Replacing a hardcoded date 3
Basic Looping 4
Activate Sheet switching 3
Function for week number 5
Wilcard for Workbooks??? 1
Need help-For loop 3
Variable SUM range 16

Back
Top