These declare three variables (names I'll use to store values) and their data type Long (Long is any number between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807)
The code to send the email copies visible cells this code:
makes sure that the screen updating is turned on so that later when we copy cells they ones mark hidden will update to hidden.
Sets the variable we declared in the first step to the last occupied row in column A. If there is data in cells in column a clear down to row 9999 then lRow = 9999.
Starts a loop that steps i (another variable declared in step one) from 4 to whatever lRow is set to (our example was 9999 but it changes based on the number of cells occupied.
This asks a question if range Ai (remember the value of i varies based on which step of the loop we're in, it has the effect of checking every occupied cell in column) is a date. If this is true then we know it could be one of the cells we want to copy. If it is then we:
set the last variable we defined to a number which is the difference between todays day date, and the date in the stepped range we're looking at.
If this comparison is more than 0 (the date is not in the past) and less than 7 (its within our timeframe therefore we want to keep it in the eamil) we can sort them out with
All the rest of the cells we will make invisible so they are not part of our email. We can accomplish this with:
The rest of this happens in code that you didn't quote -the call sendemail is another Sub with a function that creates an HTML object consisting of the visible cells in the selected range. Lastly we make all cells visible again so they can be edited if need be.
I hope this answers your question, if it does please mark that thread as [SOLVED]
Bookmarks