First, let's rule that out as a possibility. If your code doesn't work, you can never turn it into a macro and hope that it now will work. You need working code first.
You need to clarify what "previous week" means. Seven days relative to the date you run the program? (Would today's date be included or excluded?) Seven days relative to the InvoiceDate? (Again, would the invoice date be included or excluded?)
What identifies the observations you will consider? For example, do you want all observations in the previous week? All observations for the same customer?
... View more