2016-07-08 2 views
0

이 필터링 된 테이블이 비어 있는지 확인하려면 테이블에 데이터가 없을 때 전체 열을 복사하는 끝나기 때문에 확인해야합니다. 그러나, 이렇게하면 specialCells가 비어 있기 때문에 오류가 발생합니다. 이 문제를 해결할 방법이 있는지 궁금합니다.VBA 필터링 된 테이블이 비어 있는지 확인하십시오.

numberRows = Range("Table13[Store '#]").SpecialCells(xlCellTypeVisible) 
Selection.Copy 
Sheets("Style-store report").Select 
Cells(7, (3 + ((i - 4) * 3))).Select 
ActiveSheet.Paste 
+0

확인하는 것이. – cyboashu

+0

표시된 셀을 어떻게 계산합니까? SpecialCells (xlCellTypeVisible) .count를 수행하면 첫 번째 부분에서 오류가 반환되므로 여전히 오류가 반환됩니다. 거기에 또 다른 방법을 계산이 – bugsyb

+0

'Range.Cells.Count' :) – cyboashu

답변

0

이 시도 : 세포가 헤더 행을 제외한 0보다 눈에 보이는 범위에서 계산

Dim rng As Range 

'ignore any error if there are no visible rows... 
On Error Resume Next 
Set rng = Range("Table13[Store '#]").SpecialCells(xlCellTypeVisible) 
On Error Goto 0 'stop ignoring errors 

If Not rng Is Nothing Then 
    rng.Copy 
    Sheets("Style-store report").Select 
    Cells(7, (3 + ((i - 4) * 3))).Select 
    ActiveSheet.Paste 
End If 
관련 문제