multiple if then statements

  • Thread starter Thread starter Joseph Weber
  • Start date Start date
J

Joseph Weber

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
 
You need to replace the & with the word AND. & is used when you are putting
strings together "AND" is when you are putting conitional statement like A =
1 AN D B = 2.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top