Hi all,

I have a macro that autofilters data on one sheet (with a few hidden columns) and copies and pastes the visible cells to another sheet. Now I'm trying to identify the last non-blank column and row in the newly-pasted range. The problem is, it seems to be including the hidden columns and rows from the other sheet, because what shows up as the last non-blank column is 4 columns to the right (there are 4 hidden columns on the source page), and what shows up as the last non-blank row is the last row on the source page with multiple rows hidden because of the autofilters. Anyone know what I'm doing wrong? I've included the section of code below, starting with the hidden columns and autofilters on the source page. Thanks!

With data
Range("A:B").EntireColumn.Hidden = True
Range("K:K").EntireColumn.Hidden = True
Range("M:M").EntireColumn.Hidden = True
End With

With data
.AutoFilter
.AutoFilter Field:=3, Criteria1:=product
.AutoFilter Field:=4, Criteria1:=hub
.AutoFilter Field:=6, Criteria1:=begDate
.AutoFilter Field:=8, Criteria1:=endDate
.AutoFilter Field:=9, Criteria1:=optType
.AutoFilter Field:=10, Criteria1:=strPrice
Set sel = Sheets("Data").AutoFilter.Range
sel.Offset(1, 0).Resize(sel.Rows.Count - 1).Copy
Set table = Sheets("Totals").Range("A" & Rows.Count).End(xlUp).Offset(1)
table.PasteSpecial Paste:=xlPasteValues
table.PasteSpecial Paste:=xlPasteFormats
table.Select

begRow = ActiveCell.Row
begCol = ActiveCell.Column
endCol = Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Column
endRow = Cells(ActiveCell.Row, ActiveCell.Column).End(xlDown).Row
End With