Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
My question is as followed. Now the content of A2 cell is a formula like this: =BLP(A1&" "&B1, "CLOSE_DATE") Now I want to insert this formula using VBA. The range is from C1 to C10. So I code like this: for i=1 to 10 Range("C" & i).Formula="=BLP(A" & i & "&"" ""&B" & i &",""CLOSE_DATE"")" next i But it reports error. What is the correct formula then? Thanks! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Range("C1:C10") = "=BLP(A1&"" ""&B1, ""CLOSE_DATE"")"
should do what you want. -- Regards, Tom Ogilvy " wrote: Hi all, My question is as followed. Now the content of A2 cell is a formula like this: =BLP(A1&" "&B1, "CLOSE_DATE") Now I want to insert this formula using VBA. The range is from C1 to C10. So I code like this: for i=1 to 10 Range("C" & i).Formula="=BLP(A" & i & "&"" ""&B" & i &",""CLOSE_DATE"")" next i But it reports error. What is the correct formula then? Thanks! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tom.
But I am sorry, maybe I did not put it clearly. Actually, what I want is like this: Range("C1")="=BLP(A1&"" ""&B1, ""CLOSE_DATE"")" Range("C2")="=BLP(A2&"" ""&B2, ""CLOSE_DATE"")" .... Range("C10")="=BLP(A10&"" ""&B10, ""CLOSE_DATE"")" I want to put them in a loop. How to do this then? Thanks. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No, what you said was very clear and that is why I gave you the BEST answer.
What I gave you does EXACTLY that. Doing it my way is 10 times faster than looping. If you still want to do it the slow way, post back. -- Regards, Tom Ogilvy " wrote: Thanks Tom. But I am sorry, maybe I did not put it clearly. Actually, what I want is like this: Range("C1")="=BLP(A1&"" ""&B1, ""CLOSE_DATE"")" Range("C2")="=BLP(A2&"" ""&B2, ""CLOSE_DATE"")" .... Range("C10")="=BLP(A10&"" ""&B10, ""CLOSE_DATE"")" I want to put them in a loop. How to do this then? Thanks. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom's solution will load all the cells at once, adjusting the formula in
each one (well Excel does that bit). It may not seem obvious, but try it and see. -- HTH Bob Phillips (remove nothere from email address if mailing direct) wrote in message oups.com... Thanks Tom. But I am sorry, maybe I did not put it clearly. Actually, what I want is like this: Range("C1")="=BLP(A1&"" ""&B1, ""CLOSE_DATE"")" Range("C2")="=BLP(A2&"" ""&B2, ""CLOSE_DATE"")" ... Range("C10")="=BLP(A10&"" ""&B10, ""CLOSE_DATE"")" I want to put them in a loop. How to do this then? Thanks. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oh, cool!!!!!
I just tried. It works exactly. Thank you very much, Tom. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lost "File Menu" - now it's "Edit / View / Insert.." but no "F | Excel Discussion (Misc queries) | |||
Is there a formula thet reads (If A2=A1,"",INSERT PAGE BREAK) ? | Excel Discussion (Misc queries) | |||
If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ... | Excel Programming | |||
Insert "-" in text "1234567890" to have a output like this"123-456-7890" | Excel Discussion (Misc queries) | |||
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc | Excel Programming |