Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Setting AutoFilter to 1 row of data

I want to set an AutoFilter that returns 1 row of data (which works). I now
want to assign the value from each column of the 1 row data range to a label
on a User Form. I have tried to set a range (Set rgSales = Range("a1",
Range("n65536").End(xlUp)).SpecialCells(xlCellType Visible)), but I don't
know how access the range properly?

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Setting AutoFilter to 1 row of data

Try this example
posted by Dave Peterson

Sub GetFirstRow()
'posted by Dave Peterson
Dim curWks As Worksheet
Dim rng As Range
Dim rngF As Range

Set curWks = ActiveSheet

With curWks
If Not .AutoFilterMode Then
MsgBox "Please apply a filter"
Exit Sub
End If

If Not .FilterMode Then
MsgBox "you haven't filtered anything"
Exit Sub
End If

Set rng = .AutoFilter.Range

Set rngF = Nothing
On Error Resume Next
With rng
'just first column of filtered range
Set rngF = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
End With
On Error GoTo 0

If rngF Is Nothing Then
MsgBox "Filter showed nothing"
Else
.Cells(rngF(1).Row, 1).Select
End If

End With
End Sub




--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Greg Bloom" wrote in message news:ea2db.590841$YN5.431525@sccrnsc01...
I want to set an AutoFilter that returns 1 row of data (which works). I now
want to assign the value from each column of the 1 row data range to a label
on a User Form. I have tried to set a range (Set rgSales = Range("a1",
Range("n65536").End(xlUp)).SpecialCells(xlCellType Visible)), but I don't
know how access the range properly?

Thanks




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
autofilter macro setting tjb Excel Worksheet Functions 0 June 11th 08 05:36 PM
Excel - data autofilter, then data sort how do you view all Peg Excel Discussion (Misc queries) 2 April 23rd 08 11:11 PM
Setting hover data labels to cells other than source data Darren Charts and Charting in Excel 1 January 24th 06 10:20 AM
Setting hover data labels to cells other than source data Darren Excel Discussion (Misc queries) 0 January 24th 06 08:31 AM
Excel to allow color setting for autofilter drop-down arrow patriceadsl Excel Discussion (Misc queries) 1 April 25th 05 01:16 PM


All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"