Hi Steven,
Thanks for your help.
Unfortunately, i do not understand it completely.
Can you explain what i should do at the statement;
Call CellsToTextBoxes
How should i replace that with a code to fill the textboxes ?
I now have the following code to filter and then it counts the number of
lines filtered
Private Sub but_filter_Click()
'FILTER ON
Dim row_count As Double
Dim matched_criteria As Double
Dim check_row As Double
Dim datateller As Double
Columns("w:w").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=zoek_acc.Value
Set filterrange = Cells.SpecialCells(xlCellTypeVisible).Cells(1) 'your
suggestion !
Range("a1").Select
Selection.CurrentRegion.Select
row_count = Selection.Rows.Count - 1 ' Count the rows and subtract
the header.
matched_criteria = 0 ' Set variable to
zero
check_row = 0 ' Set variable to zero.
While Not IsEmpty(ActiveCell) ' Check to see if row height is
zero.
ActiveCell.Offset(1, 0).Select
If ActiveCell.RowHeight = 0 Then
check_row = check_row + 1
Else
matched_criteria = matched_criteria + 1
End If
Wend
Next i have the following code for the button "previous" (which does not
work)
Private Sub but_vorige_Click()
Do
Set filterrange = filterrange.Offset(-1, 0)
Loop While filterrange.EntireRow.Hidden = True
Call CellsToTextBoxes
End Sub
This gives an 1004 errormessage on: Loop While filterrange.EntireRow.Hidden
= True
Any suggestions on this?
Thanks,
Pierre
"Incidental" <(E-Mail Removed)> schreef in bericht
news:7378071f-8588-42c2-9285-(E-Mail Removed)...
> Hi Pierre
>
> the code below should do what you want, i set up a userform with 3
> textboxes a combobox and three buttons (1 to filter and a Next and
> Previous button) and used this code to filter data held in the range
> A1:C20 and populate the textboxes.
>
> Option Explicit
> Dim MyRng As Range
>
> Private Sub CmdFilter()
>
> With Sheets("DataDGA")
>
> Range("A1:C20").Select
>
> Selection.AutoFilter Field:=1, Criteria1:=ComboBox1.Value
>
> Set MyRng = Cells.SpecialCells(xlCellTypeVisible).Cells(1)
>
> Do
>
> Set MyRng = MyRng.Offset(1, 0)
>
> Loop While MyRng.EntireRow.Hidden = True
>
> Call CellsToTextBoxes
>
> End With
>
> End Sub
>
> Private Sub CmdPrev_Click()
>
> Do
>
> Set MyRng = MyRng.Offset(-1, 0)
>
> Loop While MyRng.EntireRow.Hidden = True
>
> Call CellsToTextBoxes
>
> End Sub
>
> Private Sub CmdNext_Click()
>
> Do
>
> Set MyRng = MyRng.Offset(1, 0)
>
> Loop While MyRng.EntireRow.Hidden = True
>
> Call CellsToTextBoxes
>
> End Sub
>
> Sub CellsToTextBoxes()
>
> TextBox1.Value = MyRng.Value
>
> TextBox2.Value = MyRng.Offset(0, 1).Value
>
> TextBox3.Value = MyRng.Offset(0, 1).Value
>
> End Sub
>
> Hope this helps you out
>
> Steven
|