clif
06-30-2012, 06:50 AM
How to change the code to search by row instead of by column?
With Range("C1:C" & Cells(Rows.Count, "C").End(xlUp).Row)
'http://www.cpearson.com/excel/FindAll.aspx
Set LastCell = .Cells(.Cells.Count)
Set FoundCell = .Find(What:="X", After:=LastCell)
If Not FoundCell Is Nothing Then
FirstAddr = FoundCell.Address
End If
Do Until FoundCell Is Nothing
FoundCell.Offset(0, -1).Select
Selection.copy
Range("I1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set FoundCell = .FindNext(After:=FoundCell)
If FoundCell.Address = FirstAddr Then
Exit Do
End If
Loop
End With
:banghead:
With Range("C1:C" & Cells(Rows.Count, "C").End(xlUp).Row)
'http://www.cpearson.com/excel/FindAll.aspx
Set LastCell = .Cells(.Cells.Count)
Set FoundCell = .Find(What:="X", After:=LastCell)
If Not FoundCell Is Nothing Then
FirstAddr = FoundCell.Address
End If
Do Until FoundCell Is Nothing
FoundCell.Offset(0, -1).Select
Selection.copy
Range("I1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Set FoundCell = .FindNext(After:=FoundCell)
If FoundCell.Address = FirstAddr Then
Exit Do
End If
Loop
End With
:banghead: