Stepheny2k2
New Member
- Joined
- Nov 23, 2009
- Messages
- 13
Hi,
I’m struggling to find a solution to the following.
I am copying data from different tabs in an excel workbook to one tab so i can pivot off the combined dataset. The VBA code works but i would like to add a check for sheets which contain no data. If there is no data(other than a header row) I want it to ignore my copying logic.
Below is an extract from my VBA code which copies from one sheet to the summary sheet:
The range lines will work as long as there is data in there. Otherwise it will presumably select 65000 blank rows.
Can anyone help me adapt the above code to check if the sheet contains no data(other than header row) before it tries to copy from it?
Thanks in advance,<!-- google_ad_section_end --> <o></o>
<o></o>
I’m struggling to find a solution to the following.
I am copying data from different tabs in an excel workbook to one tab so i can pivot off the combined dataset. The VBA code works but i would like to add a check for sheets which contain no data. If there is no data(other than a header row) I want it to ignore my copying logic.
Below is an extract from my VBA code which copies from one sheet to the summary sheet:
Code:
[COLOR=black][FONT=Verdana][SIZE=3][FONT=Times New Roman]' Copies All data added for May and pastes at the position one cell below April's dataset<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>[/FONT][/SIZE][/FONT][/COLOR][FONT=Verdana]
[COLOR=black][SIZE=3][FONT=Times New Roman] Sheets("May 2010").Select<o:p></o:p>[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman] Range("A2").Select<o:p></o:p>[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman] Range(Selection, Selection.End(xlToRight)).Select<o:p></o:p>[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman] Range(Selection, Selection.End(xlDown)).Select<o:p></o:p>[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman] Selection.Copy<o:p></o:p>[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman] Sheets("full dataset").Select<o:p></o:p>[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman] ActiveSheet.Paste<o:p></o:p>[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman] Range("A281").Select<o:p></o:p>[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman] Selection.End(xlDown).Select<o:p></o:p>[/FONT][/SIZE][/COLOR]
[COLOR=black][SIZE=3][FONT=Times New Roman] ActiveCell.Offset(1, 0).Select<o:p></o:p>[/FONT][/SIZE][/COLOR]
[/FONT]
Can anyone help me adapt the above code to check if the sheet contains no data(other than header row) before it tries to copy from it?
Thanks in advance,<!-- google_ad_section_end --> <o></o>
<o></o>