Aaron719
01-04-2014, 03:25 PM
Here's my lines of code:
ElseIf (Month(DateAdd("d", 14, dVal)) = yVal And Day(DateAdd("d", 14, dVal)) = xVal) Or (Month(DateAdd("d", 14*2, dVal)) = yVal And Day(DateAdd("d", 14*2, dVal)) = xVal) Or " _
& "(Month(DateAdd('d', 14 *3, dVal)) = yVal And Day(DateAdd('d', 14 * 3, dVal)) = xVal) Or (Month(DateAdd('d', 14 * 4, dVal)) = yVal And Day(DateAdd('d', 14 * 4, dVal)) = xVal) Then
So I want to wrap the line of code above using " _ & " but I got an error saying "Invalid Expression" with the first set of double quotes around the letter d on the second line (Month(DateAdd('d', 14 *3, dVal)). So I changed it to a single quote (as shown), not sure if the code will still work using single quotes there because I now get a different error. The new error says I'm missing a 'Then' and places my cursor after the word 'Then'. Anyone see something wrong?
As a side note I have about 10 lines that look like the above. anyway to maybe clean that up by setting parts of it equal to a label and replacing the code with that label? My only problem is that there is one number that changes in each statement between the OR's; ('d', 14 * 3, dVal)
Thanks a lot
ElseIf (Month(DateAdd("d", 14, dVal)) = yVal And Day(DateAdd("d", 14, dVal)) = xVal) Or (Month(DateAdd("d", 14*2, dVal)) = yVal And Day(DateAdd("d", 14*2, dVal)) = xVal) Or " _
& "(Month(DateAdd('d', 14 *3, dVal)) = yVal And Day(DateAdd('d', 14 * 3, dVal)) = xVal) Or (Month(DateAdd('d', 14 * 4, dVal)) = yVal And Day(DateAdd('d', 14 * 4, dVal)) = xVal) Then
So I want to wrap the line of code above using " _ & " but I got an error saying "Invalid Expression" with the first set of double quotes around the letter d on the second line (Month(DateAdd('d', 14 *3, dVal)). So I changed it to a single quote (as shown), not sure if the code will still work using single quotes there because I now get a different error. The new error says I'm missing a 'Then' and places my cursor after the word 'Then'. Anyone see something wrong?
As a side note I have about 10 lines that look like the above. anyway to maybe clean that up by setting parts of it equal to a label and replacing the code with that label? My only problem is that there is one number that changes in each statement between the OR's; ('d', 14 * 3, dVal)
Thanks a lot