Macros


Posted by Brad on January 29, 2002 11:07 AM

I have a macro that takes information from one mastersheet and copies it into another sheet all in the same workbook. How do I get the macro to highlight the information that was copied off the mastersheet so I can see if any information was missed by the macro. Attached is a copy of the macro

Public Sub CopyRows()
Sheets("Master Report").Select
' Find the last row of data
FinalRow = Range("A65536").End(xlUp).Row
' Loop through each row
For x = 2 To FinalRow
' Decide if to copy based on column D
ThisValue = Range("D" & x).Value
If ThisValue = "Brownstown PC" Then
Range("A" & x & ":E" & x).Copy
Sheets("Brown").Select
NextRow = Range("A65536").End(xlUp).Row + 1
Range("A" & NextRow).Select
ActiveSheet.Paste
Sheets("Master Report").Select
End If
Next x
End Sub


Thanks for the Help
Brad



Posted by JohnG on January 29, 2002 12:27 PM

Try this
Public Sub CopyRows()
Sheets("Master Report").Select
' Find the last row of data
FinalRow = Range("A65536").End(xlUp).Row
' Loop through each row
For x = 2 To FinalRow
' Decide if to copy based on column D
ThisValue = Range("D" & x).Value
If ThisValue = "Brownstown PC" Then
Worksheets("Master Report").Range("A" & x & ":E" & x).Copy
'Sheets("Brown").Select
NextRow = Worksheets("Brown").Range("A65536").End(xlUp).Row + 1
Worksheets("Brown").Range("A" & NextRow).PasteSpecial
'Sheets("Master Report").Select
Worksheets("Master Report").Range("A" & x & ":E" & x).Interior.ColorIndex = 3 'red
End If
Next x
End Sub