View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default copy multiple rows from a database

Hi

Try this one that use AutoFilter
You can use a inputbox if you want also

Sub Copy_with_Autofilter()
Dim FilterValue As String
Dim rng As Range
Dim rng2 As Range

Set rng = Range("A:A")
FilterValue = "test*"
rng.AutoFilter Field:=1, Criteria1:=FilterValue
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng2 Is Nothing Then
rng2.EntireRow.Copy Sheets("Sheet2").Range("A1")
End If
End With
ActiveSheet.AutoFilterMode = False
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"bradasley" wrote in message ...
I'd like to copy multiple rows based on the criteria entered into a text box,
using wildcard search capability and then be pasted onto another sheet.

Eg, copy all rows where "test*" is in column A.