schang_825
Board Regular
- Joined
- Feb 19, 2010
- Messages
- 66
Hi all,
I have created a spreadsheet that contains a summary sheet of all of the projects our company is currently working on as well as individual tabs detailing schedules and costs. When I add a new project to this spreadsheet, I have added a button that creates a new tab with pre-filled information as well as adds the project to the summary sheet with formulas linking to the new project's tab.
I have come across a problem with a certain formula I would like to add to the summary sheet. The formula works if I manually enter it into the cell, but when I want to add it via VBA, I get an "invalid character" error or and "Expected end of statement" error...
This is the formula that I would like to add upon creating a new project:
Worksheets(1).Cells(i + 2, "E").Formula = "=IF(AND(E$2>='" & ShtTitle & "'!$G19,E$2<='" & ShtTitle & "'!$H19),TEXT('" & ShtTitle & "'!$F31, "$#,##0") & CHAR(10) & "Pre-Con","")"
Worksheets(1).Cells(i + 3, "E").Formula = "=IF(AND(E$2>='" & ShtTitle & "'!$G20,E$2<='" & ShtTitle & "'!$H20),TEXT('" & ShtTitle & "'!$F31, "$#,##0") & CHAR(10) & "Const","")"
Worksheets(1).Cells(i + 4, "E").Formula = "=IF(AND(E$2>='" & ShtTitle & "'!$G21,E$2<='" & ShtTitle & "'!$H21),TEXT('" & ShtTitle & "'!$F31, "$#,##0") & CHAR(10) & "Post-Con","")"
I get the invalid character error on the $ and #. In the summary sheet, I have dates (months) going across and the projects down in Column D. The formula is looking at the month at the top of the sheet and if it is within the dates specified in the Project's tab, it lists the $$ amount for that month and whether it is "Pre-Con", "Const" or "Post-Con." I then have conditional formats that colors the cells based on this criteria.
Any help would be greatly appreciated!
Thanks!
I have created a spreadsheet that contains a summary sheet of all of the projects our company is currently working on as well as individual tabs detailing schedules and costs. When I add a new project to this spreadsheet, I have added a button that creates a new tab with pre-filled information as well as adds the project to the summary sheet with formulas linking to the new project's tab.
I have come across a problem with a certain formula I would like to add to the summary sheet. The formula works if I manually enter it into the cell, but when I want to add it via VBA, I get an "invalid character" error or and "Expected end of statement" error...
This is the formula that I would like to add upon creating a new project:
Worksheets(1).Cells(i + 2, "E").Formula = "=IF(AND(E$2>='" & ShtTitle & "'!$G19,E$2<='" & ShtTitle & "'!$H19),TEXT('" & ShtTitle & "'!$F31, "$#,##0") & CHAR(10) & "Pre-Con","")"
Worksheets(1).Cells(i + 3, "E").Formula = "=IF(AND(E$2>='" & ShtTitle & "'!$G20,E$2<='" & ShtTitle & "'!$H20),TEXT('" & ShtTitle & "'!$F31, "$#,##0") & CHAR(10) & "Const","")"
Worksheets(1).Cells(i + 4, "E").Formula = "=IF(AND(E$2>='" & ShtTitle & "'!$G21,E$2<='" & ShtTitle & "'!$H21),TEXT('" & ShtTitle & "'!$F31, "$#,##0") & CHAR(10) & "Post-Con","")"
I get the invalid character error on the $ and #. In the summary sheet, I have dates (months) going across and the projects down in Column D. The formula is looking at the month at the top of the sheet and if it is within the dates specified in the Project's tab, it lists the $$ amount for that month and whether it is "Pre-Con", "Const" or "Post-Con." I then have conditional formats that colors the cells based on this criteria.
Any help would be greatly appreciated!
Thanks!