MarkCBB
Active Member
- Joined
- Apr 12, 2010
- Messages
- 497
HI there,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o> </o>
I need to be able to offset the pasting of a database to the right of the same database once the month has been completed (i.e. all dates in the Month). In order to do this, I have built an import Worksheet that currently appends the day’s data to dump to the master database. <o></o>
<o> </o>
I am looking for some clever VBA code to work out if Column C has all the days/Dates of a month (i.e.January), it then needs to change the range to allow the next day’s/Months data to be pasted (1<SUP>st</SUP> Feb). Once all the days in February have been appended to the February range, the new pasting range is offset and then the data for March starts building. <o></o>
<o> </o>
The range of the data is A:J, the Next range needs to be K:T and so forth. The name of the worksheet that the data is being pasted is “M_DB”<o></o>
<o> </o>
I use Xl2010 when creating these tools but please also find below the code that I use to append from the input worksheet to the M_DB worksheet<o></o>
<o> </o>
<o>Maybe the trigger to Offset the range can be the Month itself so incase 1 date/day is missed the date is still by month. If it makes things easier I can build a table with the name/Number of the Month to a range i.e. 1 (For January) and the range would be A:J. </o>
<o> </o>
<o> </o>
I need to be able to offset the pasting of a database to the right of the same database once the month has been completed (i.e. all dates in the Month). In order to do this, I have built an import Worksheet that currently appends the day’s data to dump to the master database. <o></o>
<o> </o>
I am looking for some clever VBA code to work out if Column C has all the days/Dates of a month (i.e.January), it then needs to change the range to allow the next day’s/Months data to be pasted (1<SUP>st</SUP> Feb). Once all the days in February have been appended to the February range, the new pasting range is offset and then the data for March starts building. <o></o>
<o> </o>
The range of the data is A:J, the Next range needs to be K:T and so forth. The name of the worksheet that the data is being pasted is “M_DB”<o></o>
<o> </o>
I use Xl2010 when creating these tools but please also find below the code that I use to append from the input worksheet to the M_DB worksheet<o></o>
<o> </o>
<o>Maybe the trigger to Offset the range can be the Month itself so incase 1 date/day is missed the date is still by month. If it makes things easier I can build a table with the name/Number of the Month to a range i.e. 1 (For January) and the range would be A:J. </o>
<o> </o>
Code:
[SIZE=3][FONT=Calibri]Sub ImportData()<o:p></o:p>[/FONT][/SIZE]
<o:p>[FONT=Calibri][SIZE=3] [/SIZE][/FONT]</o:p>
[SIZE=3][FONT=Calibri]Dim IRng As Range<o:p></o:p>[/FONT][/SIZE]
<o:p>[FONT=Calibri][SIZE=3] [/SIZE][/FONT]</o:p>
[SIZE=3][FONT=Calibri]Sheets("INPUT").Select<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Range("A2:J2").Select<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Range(Selection, Selection.End(xlDown)).Select<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Set IRng = Selection<o:p></o:p>[/FONT][/SIZE]
<o:p>[FONT=Calibri][SIZE=3] [/SIZE][/FONT]</o:p>
[SIZE=3][FONT=Calibri]Sheets("Master_DB").Visible = True<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Sheets("Master_DB").Select<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Range("A1048576").Select<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Selection.End(xlUp).Select<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]ActiveCell.Offset(1, 0).Select<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]IRng.Copy<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]ActiveSheet.Paste<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]End<o:p></o:p>[/FONT][/SIZE]