Consulting

Results 1 to 3 of 3

Thread: Solved: What am I doing Wrong in this simple Code?

  1. #1

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

    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)

    [vba]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
    [/vba]

  2. #2
    VBAX Tutor
    Joined
    Nov 2006
    Location
    North East Pennsylvania, USA
    Posts
    203
    Location
    Saladsamurai,

    Try:

    [VBA]

    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

    [/VBA]


    Have a great day,
    Stan

  3. #3
    HA! Thanks Stan!! Maybe it's MATLAB that uses "&" or C++...I can't keep them straight!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •