![]() |
Skip copying empty column where remaining rows are filled
I have some code that looks for a header value and copies the column if a header value is found and pastes it on a new sheet. It's set up to copy non-contiguous data, so if it finds a blank cell in the data it does an xlUp to make sure it copies the entire data set.
Unfortunately, this means it still copies the column if the column is completely blank except for the header value. How can I prevent this from happening? Code:
|
Quote:
NumberofCells = Application.CountA(cell) If NumberofCells = 1 Then GoTo Skip |
Skip copying empty column where remaining rows are filled
Hi,
Am Mon, 8 Oct 2012 16:25:43 +0000 schrieb KeriM: Unfortunately, this means it still copies the column if the column is completely blank except for the header value. How can I prevent this from happening? try: For Each rngC In headerrow Select Case rngC.Value Case "Value 1", "Value 2", "Value 3" If WorksheetFunction.CountA(Columns(rngC.Column)) 1 Then LRow = Cells(Rows.Count, rngC.Column).End(xlUp).Row Range(Cells(1, rngC.Column), _ Cells(LRow, rngC.Column)).Copy Regards Claus Busch -- Win XP PRof SP2 / Vista Ultimate SP2 Office 2003 SP2 /2007 Ultimate SP2 |
Skip copying empty column where remaining rows are filled
Hi,
or try: For Each rngC In headerrow Select Case rngC.Value Case "Value 1", "Value 2", "Value 3" LRow = Cells(Rows.Count, rngC.Column).End(xlUp).Row If LRow 1 Then Range(Cells(1, rngC.Column), _ Cells(LRow, rngC.Column)).Copy Regards Claus Busch -- Win XP PRof SP2 / Vista Ultimate SP2 Office 2003 SP2 /2007 Ultimate SP2 |
All times are GMT +1. The time now is 07:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com