View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default multiple if then statements

You cannot use the & symbol for the And operator in VBA. You have to use the
word And. The & symbol is used to concatenate strings like "Hello" & "
World" would give you "Hello World".

If Range("EXPENSET") = Range("NEXPENSET") And Range("RECDATE") =
Range("NRECDATE") And Range("AMT") = Range("NAMT") And Range("EXPENST") <
"TOLLS/BRIDGES" And Range("DATESUBMIT") < Range("NDATESUBMIT") Then


would be the correct syntax for the If statement with And operators.


"Joseph Weber" wrote:

In my spreadsheet i named fields "company" "ncompany" and they are one down
from each other. I have a number of fields i am trying to test but got an
error. this is the macro so far. if anyone could help please let me know.

If Range("EXPENSET") = Range("NEXPENSET") & Range("RECDATE") =
Range("NRECDATE") & Range("AMT") = Range("NAMT") & Range("EXPENST") <
"TOLLS/BRIDGES" & Range("DATESUBMIT") < Range("NDATESUBMIT") Then
Range("EXPENSET").Select
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.copy
Application.Goto REFERENCE:="FIRSTCHECK"
ActiveSheet.Paste