View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Need help with a Macro

This should help you get started.

Sub Copy_By_Criteria()
Dim i As Integer
Dim iLastRow As Integer
Dim Collet As String
Dim Msg, Style
Set wks = ActiveSheet
Application.ScreenUpdating = False
Collet = InputBox("Choose Column Letter")
whatwant = InputBox("Choose Criteria" & Chr(13) _
& "Wildcards such as *PY* can be used")
Msg = "Run Now?"
Style = vbYesNo
Response = MsgBox(Msg, Style)
If Response = vbYes Then
iLastRow = wks.Cells(Rows.Count, Collet).End(xlUp).Row
For i = iLastRow To 1 Step -1
If wks.Cells(i, Collet).Value Like whatwant Then
wks.Rows(i).Copy Destination:= _
Sheets("Sheet7").Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
End If
Next i
End If
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP

On 2 Nov 2006 08:00:37 -0800, "Cessna Driver" wrote:

I am a "semi" newby and need help with a project.

I have a 26,000 item Excel file consisting of < 10 columns of info
(varies). I need to be able to look in a named column (variable) for a
keyword and, if found, copy that entire row to another workbook.

What I need the macro to do is ask:

"Search Which Column?"
"For What Keyword?"
"Run Now?"

and, when it finds that keyword in a column, copy the entire row to
another worksheet or workbook without destroying the info in the master
file.

I do not absolutly need to append info to the new worksheet but it
would be nice to be able to do so and I would use that function if I
had it.

This is WAY beyond my capabilities although I do know how to insert
macros.

I would think that this would be a helpful macro for many other people.
It probably has been written but I can't find it. Any help given will
be greatly appreciated.

Thanks - Jim K