Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple if then statements
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple if then statements
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. "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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Multiple IF Statements | Excel Discussion (Misc queries) | |||
Multiple IF statements looking up multiple ranges. | Excel Worksheet Functions | |||
Multiple if statements I think | Excel Worksheet Functions | |||
Multiple if statements with multiple conditions | Excel Discussion (Misc queries) | |||
Multiple If/Or Statements | Excel Worksheet Functions |