Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple IF Statements Brian Excel Discussion (Misc queries) 8 December 18th 07 04:48 PM
Multiple IF statements looking up multiple ranges. mike Excel Worksheet Functions 7 August 9th 07 04:55 PM
Multiple if statements I think DP7 Excel Worksheet Functions 2 January 30th 07 05:16 PM
Multiple if statements with multiple conditions egarcia Excel Discussion (Misc queries) 4 January 29th 07 10:46 PM
Multiple If/Or Statements scolbert Excel Worksheet Functions 3 April 24th 06 09:56 PM


All times are GMT +1. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"