Saladsamurai
09-01-2009, 02:28 PM
:) Okay then :)
I wrote this little ditty just to check the lengths of the rows of the 1st WorkSheet and compare them with the rest of the relevent WorkSheets to make sure that they have the same amount of data in each row.
It appears that they do, but I built in the MsgBox to error check and I am getting a wacky result.
The code simply runs through all of the cells in a row and checks to make sure that the two rows are of equal lengths. A row ends with the 1st empty cell.
My message box is saying that there is a problem on worksheets 7 and 8 at Cells(18, 51)
But there is NO DATA there on ANY of the worksheets.
What gives? File Attached
Sub CheckRowLengths()
Dim i As Long, j As Long
Dim k As Integer
Dim RefSheet As Worksheet
Dim RefCount As Long, Counter As Long
Set RefSheet = Worksheets("Power")
RefCount = 0
Counter = 0
For k = 2 To 8
For i = 1 To 30
For j = 1 To 50
If RefSheet.Cells(i, j) <> "" Then
RefCount = RefCount + 1
End If
If Worksheets(k).Cells(i, j) <> "" Then
Counter = Counter + 1
End If
Next j
If Counter <> RefCount Then
MsgBox i & " , " & j & " , " & k
End If
RefCount = 0
Counter = 0
Next i
Next k
End Sub
I wrote this little ditty just to check the lengths of the rows of the 1st WorkSheet and compare them with the rest of the relevent WorkSheets to make sure that they have the same amount of data in each row.
It appears that they do, but I built in the MsgBox to error check and I am getting a wacky result.
The code simply runs through all of the cells in a row and checks to make sure that the two rows are of equal lengths. A row ends with the 1st empty cell.
My message box is saying that there is a problem on worksheets 7 and 8 at Cells(18, 51)
But there is NO DATA there on ANY of the worksheets.
What gives? File Attached
Sub CheckRowLengths()
Dim i As Long, j As Long
Dim k As Integer
Dim RefSheet As Worksheet
Dim RefCount As Long, Counter As Long
Set RefSheet = Worksheets("Power")
RefCount = 0
Counter = 0
For k = 2 To 8
For i = 1 To 30
For j = 1 To 50
If RefSheet.Cells(i, j) <> "" Then
RefCount = RefCount + 1
End If
If Worksheets(k).Cells(i, j) <> "" Then
Counter = Counter + 1
End If
Next j
If Counter <> RefCount Then
MsgBox i & " , " & j & " , " & k
End If
RefCount = 0
Counter = 0
Next i
Next k
End Sub