PDA

View Full Version : Solved: What am I doing Wrong in this simple Code?



Saladsamurai
08-26-2009, 06:10 AM
I want to check the contents of each cell in "Output" and if there is a "c" in a cell and the corresponding cell in "Cold CI ISX" is NOT BLANK, then to message box the cell indices.

But it is message boxong Every cell starting at (1,1)

Sub CheckCopyPaste()

Dim i, j As Integer

For i = 1 To 25
For j = 1 To 50
If (Worksheets(2).Cells(i, j) = "c" & Worksheets(3).Cells(i, j) <> "") Then
MsgBox "There is a Problem in Cell " & i & ", " & j
End If
Next j
Next i
End Sub

stanleydgrom
08-26-2009, 06:39 AM
Saladsamurai,

Try:



Option Explicit
Sub CheckCopyPaste()
Dim i As Long, j As Long
For i = 1 To 25
For j = 1 To 50
If Worksheets(2).Cells(i, j) = "c" And Worksheets(3).Cells(i, j) <> "" Then
MsgBox "There is a Problem in Cell " & i & ", " & j
End If
Next j
Next i
End Sub




Have a great day,
Stan

Saladsamurai
08-26-2009, 06:45 AM
HA! :rofl: Thanks Stan!! Maybe it's MATLAB that uses "&" or C++...I can't keep them straight!