Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

Can someone tell me what is wrong with my 'MsgBox' code?

$
0
0

I am getting a Compile Error on this coding and can't figure out what is wrong with the line in red?

I have searched several sites to determine what might be wrong but haven't found anything that answers my issue?

    Sub MsgBoxCritical()


 Dim ws As Worksheet
 Set ws = Worksheets("Travel Expense Form")
 Dim amt As Range
 Set amt = Range("U15:U45")
 Dim proj As Range
 Set proj = Range("N15:N45")


   For Each Cell In ws("amt")
    If Cell.Value > 0 Then
   For Each Cell In ws("proj")
    If Cell.Value = "" Then Cell.Interior.Color = vbRed
        MsgBox "Project Number must be provided for all lines where 
        reimbursement is being requested"& vbCritical
        Cancel = True
   End If
End Sub

I am looking to present this message box when the workbook is saved if any cell in Column U, rows 15-45 are greater than 0 AND if the cell in Column N in the corresponding row is blank.

The compilation error I am receiving is on the line for Range U15:U45 and is an Expected:Expression error?


Viewing all articles
Browse latest Browse all 88854


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>