PDA

View Full Version : copy row based on specific value



agnesz
09-11-2008, 12:15 PM
What macro can I use to search a tab for the row that contains the word "CRP" in column S and then copy that whole row into row 502.

Then I need it to search the tab for the row that contains "CTSO" in column S and copy that whole row into row 503?

any help would be much appreciated.
tx

MaximS
09-11-2008, 01:23 PM
Hi you can use that code:



Dim CRP as Integer

CRP = Cells.Find(What:="CRP", After:=[S1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext).Row

' If you want ot copy as a values
If CRP <> 0 Then
Range("A502:S502").Value = Range("A" & CRP & ":S" & CRP).Value
End If

Dim CTSO as Integer

CTSO = Cells.Find(What:="CTSO", After:=[S1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext).Row

' If you want ot copy as a values
If CTSO <> 0 Then
Range("A503:S503").Value = Range("A" & CTSO & ":S" & CRP).Value
End If