copy multiple rows from a database
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. |
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. |
All times are GMT +1. The time now is 04:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com