Copying certain cells of data in a row - Barry Davidson
Posted by John S on October 10, 2001 2:33 PM
Here's a question to any who might be interested:
I have code that selectively finds important rows in my data.
When I get to an important row I copy only one cell, the cell
which determines if the row is important. I need to copy other
info in that row. How can i do this? Here is a simplified version
of what I'm talking about:
The "Class" column is what I use to select a row and this is done when the class
changes(ie from class1 to class2).
--C-------D-------E-------F------G------H------I---
Class1 | Junk | Length | Junk | Junk | Junk | Time |
Class2 | Junk | Length | Junk | Junk | Junk | Time |
Class2 | Junk | Length | Junk | Junk | Junk | Time |
Class3 | Junk | Length | Junk | Junk | Junk | Time |
So when Class1 changes to class2 I want to copy Class2 in column C
Length in Column E and time in column I. These are to be pasted in
another workbook in three cells(ie K,L,M). Here is code I have, provided
by Barrie Davidson, except it only copies the class data column(C)
Sub ABTID_Copy()
Dim valuetocompare
Dim currentfile As String
currentfile = ActiveWorkbook.Name
Range("C2").Select
Do Until Selection.Value = ""
If Selection.Value <> valuetocompare Then
valuetocompare = Selection.Value
Selection.Copy
Windows("Summary").Activate
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(1, 0).Activate
End If
Windows(currentfile).Activate
ActiveCell.Offset(1, 0).Activate
Loop
End Sub
Thanks In advance to anyone who can spend some time on this. I'd appreciate it.
Sincerely,
John