![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 212
|
I have been using this formula entered directly into a cell and it works fine, when I try to enter it through VB, it brings up a syntax error stopping at the 4th quote mark. Any ideas on how I can avoid this.
Worksheets("sheet1").Range("e42").formula = "=if Q42 <> "", CONCATENATE("Job Completed "&TEXT(Q42,"dd/mm/yy")" ),IF(P42<>"",CONCATENATE("Work Started "&TEXT(P42,"dd/mm/yy")),IF(O42<>"",CONCATENATE("Scheduled To Start "&TEXT(O42,"dd/mm/yy")),IF(H42<>"","Programmer Allocated",IF(M42<>"",CONCATENATE("Received By IT "&TEXT(M42,"dd/mm/yy")),""))))))" thanks Matt |
|
|
|
|
|
#2 |
|
Join Date: May 2002
Posts: 73
|
I don't think that the formula you posted can work in a cell.
Anyway, try this (might not work - haven't tried it) :- =IF(Q42 <> "", CONCATENATE("Job Completed "&TEXT(Q42,"dd/mm/yy")),IF(P42<>"",CONCATENATE("Work Started "&TEXT(P42,"dd/mm/yy")),IF(O42<>"",CONCATENATE("Scheduled To Start "&TEXT(O42,"dd/mm/yy")),IF(H42<>"","Programmer Allocated",IF(M42<>"",CONCATENATE("Received By IT "&TEXT(M42,"dd/mm/yy")),""))))) |
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
I believe your formula should be; ' ' Worksheets("sheet1").Range("e42").Formula _ "=IF(Q42<>"""",CONCATENATE(""Job Completed ""&TEXT(Q42,""dd/mm/yy""))," _ & "IF(P42<>"""",CONCATENATE(""Work Started ""&TEXT(P42,""dd/mm/yy""))," _ & "IF(O42<>"""",CONCATENATE(""Scheduled To Start ""&TEXT(O42,""dd/mm/yy""))," _ & "IF(H42<>"""",""Programmer Allocated"",IF(M42<>"""",CONCATENATE(""Received By IT ""&TEXT(M42,""dd/mm/yy"")),"""")))))" |
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 212
|
Thanks guys
Ivan - tried your method and getting the error object doesn't support this property/method. Any ideas thanks Matt [ This Message was edited by: Matt on 2002-05-16 06:56 ] |
|
|
|
|
|
#5 |
|
Join Date: May 2002
Posts: 73
|
I think Ivan inadvertently missed out an = sign. First line should be :-
Worksheets("sheet1").Range("e42").Formula = _ |
|
|
|
|
|
#6 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
' ' Worksheets("Sheet1").Range("e42").Formula = _ "=IF(Q42<>"""",CONCATENATE(""Job Completed ""&TEXT(Q42,""dd/mm/yy""))," _ & "IF(P42<>"""",CONCATENATE(""Work Started ""&TEXT(P42,""dd/mm/yy""))," _ & "IF(O42<>"""",CONCATENATE(""Scheduled To Start ""&TEXT(O42,""dd/mm/yy""))," _ & "IF(H42<>"""",""Programmer Allocated"",IF(M42<>"""",CONCATENATE(""Received By IT ""&TEXT(M42,""dd/mm/yy"")),"""")))))" |
|
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
maybe a liitle less haste........ |
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 212
|
Top Man, that's perfect, thanks again to both of you!
|
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 212
|
Sorry Guys to bother you again, I'm trying to force a variable into the equation "row", which changes the row that the formula calculates. At the moment, the variable appears in the formula as text and not as the variable integer as it should. I know the variable is Ok as it appears in the same procedure out of a formula and functions correctly. Hope you can help
Formula used: Worksheets("sheet1").Range("e" & row).Formula = "=IF(Q & row<>"""",CONCATENATE(""Job Completed ""&TEXT(Q & row,""dd/mm/yy""))," _ & "IF(P & row<>"""",CONCATENATE(""Work Started ""&TEXT(P & row,""dd/mm/yy""))," _ & "IF(O & row<>"""",CONCATENATE(""Scheduled To Start ""&TEXT(O & row,""dd/mm/yy""))," _ & "IF(H & row<>"""",""Programmer Allocated"",IF(M & row<>"""",CONCATENATE(""Received By IT ""&TEXT(M & row,""dd/mm/yy"")),"""")))))" Formula that appears in cell =IF(Q & row<>"",CONCATENATE("Job Completed "&TEXT(Q & row,"dd/mm/yy")),IF(P & row<>"",CONCATENATE("Work Started "&TEXT(P & row,"dd/mm/yy")),IF(O & row<>"",CONCATENATE("Scheduled To Start "&TEXT(O & row,"dd/mm/yy")),IF(H & row<>"","Programmer Allocated",IF(M & row<>"",CONCATENATE("Received By IT "&TEXT(M & row,"dd/mm/yy")),""))))) thanks Matt [ This Message was edited by: Matt on 2002-05-16 07:24 ] [ This Message was edited by: Matt on 2002-05-16 07:33 ] |
|
|
|
|
|
#10 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
Try this:
Worksheets("sheet1").Range("e" & Row).Formula = "=IF(Q" & Row & "<>"""",CONCATENATE(""Job Completed ""&TEXT(Q" & Row & ",""dd/mm/yy""))," _ & "IF(P" & Row & "<>"""",CONCATENATE(""Work Started ""&TEXT(P" & Row & ",""dd/mm/yy""))," _ & "IF(O" & Row & "<>"""",CONCATENATE(""Scheduled To Start ""&TEXT(O" & Row & ",""dd/mm/yy""))," _ & "IF(H" & Row & "<>"""",""Programmer Allocated"",IF(M" & Row & "<>"""",CONCATENATE(""Received By IT ""&TEXT(M" & Row & ",""dd/mm/yy"")),"""")))))" Since you are just creating a huge string, you have to keep the row variable outside of the quotes so that it will use its value and not the string row. K |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|