D
DBarnard
I'm having difficulty with the following code. It checks a row (B co
through end column) and any mismatching information, it marks as a re
background. This code works fine if I manually type in information
but does not work if I paste information in (single or multipl
entries). The weird thing is, the debugging statements still writ
either way. Any ideas?
Here's the code:
Public Sub Worksheet_Change(ByVal Target As Range)
Dim A_Range As Range, rngCheck As Range
Dim EndCol As Long, EndRow As Long, OffsetRow As Long, RowNum A
Long, tempRow As Long
Set A_Range = Excel.Union(Range("A7:A38"), Range("A42:A57")
Range("A62:A69"), Range("A75:A78"), Range("A84:A85"), Range("A91"))
If Not Intersect(Target, A_Range) Is Nothing Then
EndCol = UsedRange.Columns.Count
Do While Cells(1, EndCol) = ""
EndCol = EndCol - 1
Loop
Debug.Print "End Col = " + CStr(EndCol)
EndRow = Target.Rows.Count
Debug.Print "End Row = " + CStr(EndRow)
OffsetRow = Target.Offset.row - 1
Debug.Print "Offset = " + CStr(OffsetRow)
For RowNum = 1 To EndRow
If Target(RowNum, 1).Value <> "" Then
tempRow = RowNum + OffsetRow
For ndx = 2 To EndCol
If Cells(tempRow, ndx).Value <> Target(RowNum
1).Value Then
Cells(tempRow, ndx).Interior.ColorIndex = 3
Debug.Print CStr(tempRow) + "," + CStr(ndx)
"=Red"
End If
Next ndx
End If
Next RowNum
End If
End Su
through end column) and any mismatching information, it marks as a re
background. This code works fine if I manually type in information
but does not work if I paste information in (single or multipl
entries). The weird thing is, the debugging statements still writ
either way. Any ideas?
Here's the code:
Public Sub Worksheet_Change(ByVal Target As Range)
Dim A_Range As Range, rngCheck As Range
Dim EndCol As Long, EndRow As Long, OffsetRow As Long, RowNum A
Long, tempRow As Long
Set A_Range = Excel.Union(Range("A7:A38"), Range("A42:A57")
Range("A62:A69"), Range("A75:A78"), Range("A84:A85"), Range("A91"))
If Not Intersect(Target, A_Range) Is Nothing Then
EndCol = UsedRange.Columns.Count
Do While Cells(1, EndCol) = ""
EndCol = EndCol - 1
Loop
Debug.Print "End Col = " + CStr(EndCol)
EndRow = Target.Rows.Count
Debug.Print "End Row = " + CStr(EndRow)
OffsetRow = Target.Offset.row - 1
Debug.Print "Offset = " + CStr(OffsetRow)
For RowNum = 1 To EndRow
If Target(RowNum, 1).Value <> "" Then
tempRow = RowNum + OffsetRow
For ndx = 2 To EndCol
If Cells(tempRow, ndx).Value <> Target(RowNum
1).Value Then
Cells(tempRow, ndx).Interior.ColorIndex = 3
Debug.Print CStr(tempRow) + "," + CStr(ndx)
"=Red"
End If
Next ndx
End If
Next RowNum
End If
End Su