View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Copying row into new sheet if it contains certain text

Hi,

Am Mon, 28 Jan 2013 16:38:38 +0000 schrieb K.Fell:

So in Sheet1 of my file I want to copy out all rows that contain "Milka"
in column I. This column contains other names in each cell, but I just
want to take out ones that contain Milka (can contain other names
also).


try:
Sub Test()
Dim LRow1 As Long
Dim LRow5 As Long
Dim rngC As Range

With Sheets("Sheet1")
LRow1 = .Cells(.Rows.Count, 1).End(xlUp).Row
For Each rngC In .Range("I1:I" & LRow1)
If rngC = "Milka" Then
LRow5 = Sheets("Sheet5").Cells(Rows.Count, 1).End(xlUp).Row + 1
rngC.EntireRow.Copy Sheets("Sheet5").Cells(LRow5, 1)
End If
Next
End With
End Sub



Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2