View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
MSP77079[_15_] MSP77079[_15_] is offline
external usenet poster
 
Posts: 1
Default Filtered Rows / Numeric Data - Automate Position of Total on Worksheet

The question is not entirely clear. I assume that you are doing th
following:
+ DataFilterAutoFilter
+ selecting an AutoFilter value
+ selecting/copying visible cells
+ pasting this to another worksheet

You want to know how to find out the last row in the worksheet you jus
pasted to.

There are at least 3 ways.
1) my favorite would be to use CurrentRegion in the new worksheet
Set myRange = Range("C4").CurrentRegion
LastRow = myRange.Cells(myRange.Cells.Count).Row
2) quick and dirty, works only if there are no blanks in column C
LastRow = Range("C4").End(xlDown).Row
3) will find the absolute last row ever used in this worksheet
LastRow = ActiveSheet.Cells.SpecialCells(xlLastCell).Row

If my assumptions are wrong, and you want to find out what was the las
row number in the original table, then you would do something lik
this:

'set LastTableRow equal to the last row of data in the datatable
LastVisibleRow = FirstTableRow
For i = FirstTableRow to LastTableRow
if cells(i, "C").entirerow.hidden = False then LastVisibleRow = i
Next Ro

--
Message posted from http://www.ExcelForum.com