• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Syntax error

Could I get a second set of eyes on the following code? I am getting a 'Syntax error' on the code string that begins with 'If myCell.value>0' (7th row down). I can't see what is wrong... does anyone else? Strange thing is that it worked last night before I saved for the night and I haven't made any changes since and now the error. UGH I'm confused. :)

Code:
Public Sub ProjNumbrReq()
'Call ProjNumbrReq
Dim myCell As Range
With Worksheets("Travel Expense Voucher")
  If .Range("F5") = 2 Then
       For Each myCell In .Range("W16:W46")
       If myCell.Value>0,And.Cells(myCell.row,"N")="" Then
        MsgBox "Project Number must be provided on each line where reimbursement is being claimed.", vbCritical, "Important:"
        Exit Sub
       End If
     Next myCell
  End If
End With
End Sub
 
Last edited:
Hi ,

I don't get any error with this code :
Code:
Public Sub ProjNumbrReq()
'      Call ProjNumbrReq
       Dim myCell As Range
       With Worksheets("Travel Expense Voucher")
            If .Range("F5") = 2 Then
               For Each myCell In .Range("W16:W46")
                   If myCell.Value > 0 And .Cells(myCell.Row, "N") = "" Then
                      MsgBox "Project Number must be provided on each line where reimbursement is being claimed.", vbCritical, "Important:"
                      Exit Sub
                   End If
               Next myCell
            End If
       End With
End Sub
Narayan
 
Hi ,

I don't get any error with this code :
Code:
Public Sub ProjNumbrReq()
'      Call ProjNumbrReq
       Dim myCell As Range
       With Worksheets("Travel Expense Voucher")
            If .Range("F5") = 2 Then
               For Each myCell In .Range("W16:W46")
                   If myCell.Value > 0 And .Cells(myCell.Row, "N") = "" Then
                      MsgBox "Project Number must be provided on each line where reimbursement is being claimed.", vbCritical, "Important:"
                      Exit Sub
                   End If
               Next myCell
            End If
       End With
End Sub
Narayan


I just got to looking, I have errors in the range noted above because I'm working on some other formulas... would that be returning the error? The errors on the form that I am working on show a #value error. I wonder if that is what is doing it? Maybe I need to focus on one thing at a time. :(
 
Kristen_cancerkiller
You should reread Forum rules,
especially about cross-posting.
 
Back
Top