View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Cells.find only reporting range in AutoFilter...


Sub GetLastCol()
MsgBox ReallyLastColumn
End Sub
'--
Function ReallyLastColumn()
Dim lngCol As Long
Dim N As Long
Dim lngRow As Long
With ActiveSheet.UsedRange
lngRow = .Rows(.Rows.Count).Row
End With
For N = 1 To lngRow
With ActiveSheet
lngCol = Application.Max(lngCol, .Cells(N, .Columns.Count).End(xlToLeft).Column)
End With
Next
ReallyLastColumn = lngCol
End Function
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"mark"
wrote in message
If my intent were to turn off the auto-filter, then sure, I could do that, no
problem.

But that's not my intent. I guess I didn't state the problem well enough.

After the operations that my code will perform, I still want the autofilter
to be on; in fact, having it on will cause my code to need to do less work.

So, I don't want to turn it off. I could turn it off, find the cell
intersection, and then turn it back on, but then I'd have to write in an
array to remember what all the selected filters in the auto filter were, and
I wasn't in a mood to bother with that today, either.

I think I can do it by a combination of the usedrange.columns.count , and
the position of the first column in the used range (since Excel doesn't count
blank columns on the left as part of the used range, if there is nothing in
them).