Updating formula in Excel via VBA

GeneralShamu

Board Regular
Joined
Jul 6, 2007
Messages
127
I am using a Bloomberg API import function that does not update automatically.

I am running a macro that depends on this cell updating. If you manually go into it by hitting 'F2' and then exit by hitting 'Enter.'

I tried recording a macro where I select the cell and go through these key strokes but I am unsure what htis is doing...

Range("B4").Select
ActiveCell.FormulaR1C1 = "=Formula1(xxx,xxx,xxx)"
Range("B5").Select
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
It's a Bloomberg function (bdh)...there is no function call per say.

Sorry, i have no experience with this kind of function. I was thinking it was a function called by vba code, like
myVar = myFunction(argument1, argument2...)

Maybe someone else can help you.

M.
 
Upvote 0
No need to apologize; I appreciate your assistance!

Tks for your kind words.

So, let me say what was my idea. Create a volatile-function that would indirectly calls the main-function, ie, something like

Code:
Function CallsIndirect(argument1 As Long, argument2 As Long) As Variant
    Application.Volatile
    CallsIndirect = MainFunction(argument1, argument2)
End Function

But, i think it would not work for you...

M.
 
Upvote 0
I think this might work...

If the Bloomberg API has more than a single "formula1" then comment out the "if" and "end if" statements (but leave the line in between).

This basically simulates going through and hitting 'F2 + Enter' on cells with formulas that contain "formula1".

Code:
Sub Macro1()
   
    
    Dim cellswithformulas As Range, cell As Range
    Dim text_to_search As String
   
   
    text_to_search = "formula1("
    Set cellswithformulas = ActiveSheet.usedrange.SpecialCells(xlCellTypeFormulas)
    
    For Each cell In cellswithformulas
        
        If InStr(1, cell.Formula, text_to_search, vbTextCompare) <> 0 Then
            cell.Formula = cell.Formula
        End If

    Next cell
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,183
Members
452,893
Latest member
denay

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