View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Filter question?

How are you displaying those 32 columns?

If it's part of a giant listbox or combobox, then if you were only using up to
10 columns, you could loop through the important column and add each item that
matches your requirement -- and include the cells to the right.

But since you're using columns A:AF (32 columns), you can filter your range to
show what you want.

Then copy the visible rows to a new location (on a new worksheet--maybe
hidden???). Then use the range on that worksheet as the rowsource.

If you're displaying each of those fields in a separate textbox (or label or
....), you could loop through the visible cells in column A and do something
like:

Dim HowManyVisRows as long
dim VisRng as range
dim myCell as range
dim iCtr as long

'apply the filter someway

With worksheets("somesheetname").autofilter.range
'subtract one for the header.
howmanyvisrows _
= .columns(1).cells.specialcells(xlcelltypevisible). cells.count - 1

if howmanyvisrows 0 then
'avoid the header and come down one row
set visrng = .resize(.rows.count-1, 1).offset(1,0) _
.cells.specialcells(xlcelltypevisible)
else
set visrng = nothing
end if
end with

if visrng is nothing then
'warning message???
else
for each mycell in visrng.cells
me.textbox1.value = mycell.value
me.textbox2.value = mycell.offset(0,1).value
'etc
'or if the textboxes are named nicely.
for ictr = 1 to 32
me.controls("Textbox" & ictr).value = mycell.offset(0,ictr-1).value
next ictr
end if

Untested, uncompiled--watch for typos.


AOP wrote:

At the moment I have a data sheet that details are entered using a userform.
It finds the last empty row and enters the data from columns "A" to "AF"
Is there a way in which I can filter by name (column "A") and the result be
shown on the same userform in which data was entered. Or do I have to use a
different userform.
--
AOP


--

Dave Peterson