Hello All,
I am trying to write a code that will copy data from one workbook (one sheet) to another workbook. I can do that. My problem is, I want the data pasted on a specific worksheet in second workbook based on a date range. Say if the cell in B1 of first worksheet contains a date, and that date is between 6/1/07 and 8/31/07 i want it to go to sheet 1 in second workbook. 4 worksheets in second workbook (4 quarters in a year).
This is my code. It stops at the second line of code after the 'And' at the 'Range' and I get an error message telling me:
Compile Error:
Else without If
I guess I'm dense, but I just don't understand why it's debugging.
I am trying to write a code that will copy data from one workbook (one sheet) to another workbook. I can do that. My problem is, I want the data pasted on a specific worksheet in second workbook based on a date range. Say if the cell in B1 of first worksheet contains a date, and that date is between 6/1/07 and 8/31/07 i want it to go to sheet 1 in second workbook. 4 worksheets in second workbook (4 quarters in a year).
Code:
If Range(b1) >= #6/1/2007# And Range(b1) <= #8/31/2007# Then Sheets("1st qtr").Select
ElseIf Range(b1) >= #9/1/2007# And Range(b1) <= #11/30/2007# Then Sheets("2nd qtr").Select
ElseIf Range(b1) >= #12/1/2007# And Range(b1) <= #2/28/2008# Then Sheets("3rd qtr").Select
ElseIf Range(b1) >= #3/1/2008# And Range(b1) <= #5/31/2008# Then Sheets("4th qtr").Select
End If
This is my code. It stops at the second line of code after the 'And' at the 'Range' and I get an error message telling me:
Compile Error:
Else without If
I guess I'm dense, but I just don't understand why it's debugging.