Need a Macro to enter formula

vijayamani1987

New Member
Joined
Mar 16, 2014
Messages
32
Hi people,

I am using a user defined function formula in my excel sheet. The formula is


PlaceBO = (Exch, TrdSym, Trans, Qty, LmtPrice, SqOffValue, StoplossValue, TrailPoints, OrdType, TrgPrice, cTag)


I am using this for trading. The problem is I am manually editing the formula every time. I tried CONCATENATE formula which gives value as follows,


PlaceBO("NSE","sail","BUY",100,600,2,2,0)


Problem is again I needed to double click that cell and enter symbol "=" at the beginning of the formula. How can I make it through VBA. Please through some light. Thank you
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
.
Presuming for this example, you want the formula to go in Sheet #1 / Cell B8:

Code:
Option Explicit


Sub entForm()
Sheets("Sheet1").Range("B8").Value = "=PlaceBO(""NSE"",""sail"",""BUY"",100,600,2,2,0)"
End Sub

Note there is a quotation marks at the beginning and end of the formula. Also, if there are quotation marks required within the formula itself, there must be an additional
quotation mark next to it. When the formula is pasted into the cell, the extra quotation marks are not transferred to the cell.

Also, there is no way for me to know if your formula actually works. The example is based off what you have posted.
 
Upvote 0
Hi Logit,

Thank you. It's working and placing orders. But I need it work in other way. Perhaps I didn't explained my problem clearly. Below is the actual sheet.
ABCDEFGHIJ
1ExchTrdSymOrdTypeQtyLmtPriceSL
TSLorder formatPlace Order
2NSEDABURBUY6041031=PlaceBO("NSE","DABUR","BUY",60,410,3,1)
3NSEASHOKLEY
4NSEHCLTECHSELL2591561=PlaceBO("NSE","HCLTECH","SELL",25,915,6,1)
5NSEITC
6NSENTPCSELL200650.80=PlaceBO("NSE","NTPC","SELL",200,65,0.8,0)
7NSETATAGLOBALBUY8020110=PlaceBO("NSE","TATAGLOBAL","BUY",80,201,1,0)
8NSEWIPRO

<colgroup><col><col><col><col><col><col><col span="2"><col><col><col><col></colgroup><tbody>
</tbody>
In your code the formula contains exact values. But the values in columns D:H keep changing. And so the values in column I. What I am currently doing is whenever a order formula appears at column "I", I will copy it manually and paste it in adjacent cell at column J. Then in that cell (in column J) I have to double click and press enter. Then only the order will pass.

Your code is passing the order. But I need it to search it in column I for orders and place it in column J.

Thanks in advance.

<colgroup><col><col><col><col><col><col><col span="2"><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top