Dear all,
I am looking for someone to write an example piece of code to demonstrate how to achieve taking into account the current month of the year when copying data from one workbook to another. This is for something I am writing a macro for and am learning as I go.
For the purpose of this, I attached an example of the source data workbook, and the target workbook into which certain lines of data need to be copied. The source workbook is entitled "SOURCEDATAEXAMPLE", and the target workbook is entitled "Sales Analysis Template1".
What I want this example Macro to do is find all the lines in the source workbook that match "AREA 1" in column A, "SALES" in column D, and "2014" in column F. For each of these lines I want to copy the data from columns B&C and paste in columns A&B in the target workbook, on the 2014 sheet. Also for these lines I want to copy the data from columns G-R in the source workbook, and paste to columns C-N in the target workbook, on the 2014 sheet.
Now here is the part regarding the current month...
The data in columns G-R in the source workbook represent sales figures for the months of the year, i.e. Jan-Dec. I want the macro to only copy the figures from the source workbook to the target up until the current month of the year (not including the current month), and for this to always work correctly weather it is run now, or later in the year etc. So we need to copy the figures starting from column G and going up to which ever column depending on what month of the year it is now, and then paste the data into the respective columns in the target workbook, starting from column C and going up to whatever it is.
So running it right now in April, it should copy columns G-I from the source workbook and paste into columns C-E on the target workbook. If run next month it would need to be columns G-J from the source copied to columns C-F on the target, and so on.
Hopefully I have explained enough for you to understand exactly what I am looking for.
If anyone could have a go at this for me it would be much appreciated.
Many thanks in advance.
Bookmarks