I'm sure this question has been answered numerous times, but brain farts are preventing me from finding it.
I'm trying to create a macro that will cell-by-cell look at a range of data on Sheet1 and conditionally apply a "1" to Sheet2 and copy the cell to Sheet4. I've gotten this to work by doing
For CountRow = 1 To Size
For CountCol = 1 To Size
If ActiveCell.Interior.ColorIndex = 3 Then
Sheets("Sheet2").Select
ActiveCell.Value = 1
ActiveCell.Offset(0, 1).Select
Sheets("Sheet4").Select
ActiveCell.Interior.ColorIndex = 3
ActiveCell.Offset(0, 1).Select
Else
Sheets("Sheet2").Select
ActiveCell.Offset(0, 1).Select
Sheets("Sheet4").Select
ActiveCell.Offset(0, 1).Select
End If
Sheets("Sheet1").Select
ActiveCell.Offset(0, 1).Select
Next CountCol
Sheets("Sheet2").Select
ActiveCell.Offset(1, (Size * -1)).Select
Sheets("Sheet4").Select
ActiveCell.Offset(1, (Size * -1)).Select
Sheets("Sheet1").Select
ActiveCell.Offset(1, (Size * -1)).Select
Next CountRow
However, I'm sure there's easier (thus faster) way to do this without having to jump from sheet to sheet. I know I can populate the ActiveCell that will detect a value on another sheet using relative coordinates (ActiveCell.FormulaR1C1 = "='Sheet2'R[-1]C[-1]", for example), but I haven't figured out a way to do this using things that aren't Worksheet formulas.
I tried doing:
For CountRow = 1 To Size
For CountCol = 1 To Size
If ActiveCell.Interior.ColorIndex = 3 Then
Range("Sheet2!RC").Value = 1
End If
ActiveCell.Offset(0, 1).Select
Next CountCol
ActiveCell.Offset(1, (Size * -1)).Select
Next CountRow
Attempting to only have to offset the cell on Sheet1, but that didn't work. However, I think I'm on the right path. Any help would be greatly appreciated. Thanks.
Bookmarks