Visual Basic for Applications (VBA)


Formula does not calculate


I have a piece of code that does the following:
Grabs a cell.value from another worksheet places it in the new worksheet A1
Formula in B1 reads A1 and should update resulting in a string
Unfortunately this Formula does not update unless i exit the macro.  The formula is:
Developed by a third party 
I have tried to do this Range("B1").calculate
Put timer loops to give the formula time to pull the data it needs
None of this works unless I exit the macro, the minute I do the Formula gives the desired result.
Thank you in advance
"is it worth going public to get help?"that is something only you can answer but is an interesting question to think about.some things i would keep in mind are: would you be creating something that hasn't been created beforedo you expect at some point for others to see what you createdare you going to keep it for yourself only and don't want anyone else to know about itif you don't get help on it, can you finish itmain thing i try to consider when working on a project is that i have never really created anything that hasn't been done before. of course it is not exactly like everthing else but it's not something revolutionary and will change the world so i should keep it hush-hush.i guess overall i look at it this way, at some point if your project will be out in the open, someone will know about it anyway. will someone knowing about it before it is finished change anything. you will have to answer that one for yourself.i have a different perspective on software and ownership than i used to. at times i have thought that i don't want anyone to get my software without paying for it, etc... but after some time i realized that keeping it from people just made it less useful. i have changed my outlook and have now focused on ways to give everyone my software for free but still get compensation for my time so i can continue on creating more and better software. software providing help to someone is better than keeping it from them in order to retain some monetary gain. of course in a business it may rely on getting paid for software and can't afford to not make efforts as best it can to protect it. but if you really think about it, the problem is not protecting it, the problem is that the business is only thought to have succeeded if it generates enough profit. it's not the protection that makes or breaks a business, it's the idea that it must produce a certain return, and does not. the idea is the fall of the business.my overall thinking is that having a business is great to help you become independent and earn money to live, but it's main goal should be to perform a service or product that helps others and not just it's own wallet.you will have to decide for yourself what the goal for your software is and proceed based on that. if you need to protect it then you should proceed with that in mind.all that aside, an easy transition for you might be to look at vb.net or C# in visual studio and take advantage of SpreadsheetGear for .NET. but that is just a suggetion, if you want to do it all from scratch then any language and any tool can be used pretty much.alright, i need to get out of here and focus on some work, hope my rambling has helped in some way. good luch with the project and maybe i will see you in the .NET forums.peace
FREE
DEVELOPER
TOOLS CODE PROJECTS
DATABASE CODE GENERATOR
DATABASE / GENERAL APPLICATION TUTORIAL
Upload Projects to share or get help on and post the
generated links here in the forum
www.srsoft.us
In the ribbon in fromulas tab set Caluclation Options to automatic and try...Thanks
Dileep
No that is not it, I spoke to a vendors developer and he is talking about an Async process.  I am trying to understand that but ... confused is a kind word.
Hi,Have you tried Application.calculate method? Could you gave us a pice of code that demonstrates how the programme works?Thanks.Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Hi,Have you tried Application.calculate method? Could you gave us a pice of code that demonstrates how the programme works?Thanks.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Yes I have.  The formula by the third party is a function that gets "market data", so you can get realtime stock quotes, option symbols, prices ect, depending on the parameters that go in the function.  The developer uses an .OnTime line of code to make it work inside a macro.
'The macro's problem is that it does not have a notification (waiting) mechanism.  When you put in a request like , you will get UD right away.  The real result will not come until RTD send the request to the server, and then server has to send the result back.  Only by that time you will have the result.  It is what we call an async process."
 
I have not found anything on Async process on my own, is there another name for this?  My code goes something like this:
'This formula is in Worksheet("Option_Chain").Range("B1")
" "=RTD(""activrtd"","""",""realtime"",RC[-2],""Last(0,12;0,113)"")"
For i=2 to number_index_components
Range("ticker_symbol").value = Worksheets("Index_Inputs").Cells(i,1).value 'Ticker symbol
Range(b1").select
Call ParseList
'Copy range
'Paste range
'Do some calc
'Clear range
next i
To sum it up I dont receive any result from the formula until the Macro is finished or I terminate it along any point.  
Thanks again, I want to understand this.
 
Hi,I do have exactly the same problem as above with the same type of application. I've tried few little thing but unsuccessfully.Application.wait or Application.calculate method don't work either.The formula =RTD.... only update itself once you break out of the code. same thing if you run the code step by step. So I can't wait to see what is the work around this problem.
this may help give you some ideas on how you can work around this until you find the "answer"Sheet1 code
Sub ChangeA1ValueToTriggerB1FormulaUpdate()
Me.Range("A1").Value = 2
End Sub
Sub ProcessRestOfDataAfterB1FormulaUpdate()
MsgBox ("rest of data processed")
End Sub
ThisWorkbook code
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim shtaffected As Worksheet
Set shtaffected = Sh
If shtaffected.Name = "Sheet1" And Target.Address = "$A$1" Then
Sheet1.ProcessRestOfDataAfterB1FormulaUpdate
End If
End Sub
what i did was use the sheetchange event in the workbook to determine if sheet1 range A1 was changed. this is the cell that B1 formula looks at to calculate it's fomula.in sheet1 code i used a macro to change the value in A1 and stops. this will trigger the sheetchange event to fire and the check will be performed to see if the correct sheet1 range A1 was changed.being that B1 formula is dependent on A1 value change, i know that B1 will be updated. since i only use the macro to update A1 and stop, B1 formula should change to show the real time data and then fire the sheetchange event to process the remaining data that is needed after updating the formula.of course this is not exactly what you are trying to do but you can make some adjustments to your loop to process in a few steps this way. since you are using a loop you may have to figure a way to know the count in between calls; you can do this with a variable outside your subs.keep in mind i have not tested this will real time data or the formula you are using, so this may not do the trick, but if the processing is dependent on breaking the macro code so it can update then this may give it the break it needs to refresh. other possible last resort may be to use a timer but i think being that vba is single thread, this may not do any good. i have not played with timers in vba so i can't say much else about them.if this is something that is a big concern, are not able to make any of the above work and do not find any other solution, my last suggestion would be to look at visual studio. if you are not familiar with it, visual studio is the development environment for .net; this includes c++, C# and vb.net. there are free express editions that include just one language such as vb.net or c#, but the free versions are very only limited in certain ways, the code is the same. and with the visual studio and .net you can take advantage of automating excel from inside your application or you can use integrated spreadsheet tools such as SpreadsheetGear for .NET, which will allow you to work with excel files without the need for excel. it is not fully compatible with all excel features but it is a very good tool. so the just of it, you would have much more control over how your application handles your workbooks. the full versions of visual studio are not free but they do have VSTO which is visual studio tools for office. these tools allow you to create stand along projects to integrate workbooks into your application or create addins for vba. i am not fully sure if VSTO template projects require the user to have office to be installed on their computer or not. i have not looked into it that deep. the only solution i know of for sure that does not require office to be installed is the third party spreadsheet tools; and there are some others out there such as Gembox and FarPoint Spread, but SpreadsheetGear has the best free version. the free version you can get in your registration benefits when you register visual studio.ok well i hope this helps. i don't know why your issue exists, i just know that vba is a different kind of animal. many times i see issues like this and i just say well, that's just how it is, and have to look for a work around. some small issues like this are why i ended up moving to .net a few years ago. i really enjoy vba but the power that .net and a stand alone application gives you is very nice.Peace
FREE
DEVELOPER
TOOLS CODE PROJECTS
DATABASE CODE GENERATOR
DATABASE / GENERAL APPLICATION TUTORIAL
Upload Projects to share or get help on and post the
generated links here in the forum
www.srsoft.us
Thank you Jeff,I've implemented your code but no change, the RTD doesn't update unless you break out. So I splitted my code into 2 parts and with 2 buttons which I click #1 for looping through a table while I put a flag telling the next function where part 1 stop. Then #2 continue on with the rest of the operation. I bugs me but if this is the limitation like you said, it may be time to try a different language. I do actually have visual studio, however it has been over 10+ years I haven't touched C++. I do have a major project in my head I'd been thinking for several years but since I don't really know how and where to start, I am aiming at something like QStalker but with other modules/function. I want to start straight from scratch, I've found already some open source codes out there such as TA_LIB and others which will be of very good use. So I bit more reading and I'll start eventually. Since this would be my first major one, I am not sure how to proceed, is is worth it going public and getting help from various people or not? I can't tell yet but might be the way to go. Cheers 
"is it worth going public to get help?"that is something only you can answer but is an interesting question to think about.some things i would keep in mind are: would you be creating something that hasn't been created beforedo you expect at some point for others to see what you createdare you going to keep it for yourself only and don't want anyone else to know about itif you don't get help on it, can you finish itmain thing i try to consider when working on a project is that i have never really created anything that hasn't been done before. of course it is not exactly like everthing else but it's not something revolutionary and will change the world so i should keep it hush-hush.i guess overall i look at it this way, at some point if your project will be out in the open, someone will know about it anyway. will someone knowing about it before it is finished change anything. you will have to answer that one for yourself.i have a different perspective on software and ownership than i used to. at times i have thought that i don't want anyone to get my software without paying for it, etc... but after some time i realized that keeping it from people just made it less useful. i have changed my outlook and have now focused on ways to give everyone my software for free but still get compensation for my time so i can continue on creating more and better software. software providing help to someone is better than keeping it from them in order to retain some monetary gain. of course in a business it may rely on getting paid for software and can't afford to not make efforts as best it can to protect it. but if you really think about it, the problem is not protecting it, the problem is that the business is only thought to have succeeded if it generates enough profit. it's not the protection that makes or breaks a business, it's the idea that it must produce a certain return, and does not. the idea is the fall of the business.my overall thinking is that having a business is great to help you become independent and earn money to live, but it's main goal should be to perform a service or product that helps others and not just it's own wallet.you will have to decide for yourself what the goal for your software is and proceed based on that. if you need to protect it then you should proceed with that in mind.all that aside, an easy transition for you might be to look at vb.net or C# in visual studio and take advantage of SpreadsheetGear for .NET. but that is just a suggetion, if you want to do it all from scratch then any language and any tool can be used pretty much.alright, i need to get out of here and focus on some work, hope my rambling has helped in some way. good luch with the project and maybe i will see you in the .NET forums.peace
FREE
DEVELOPER
TOOLS CODE PROJECTS
DATABASE CODE GENERATOR
DATABASE / GENERAL APPLICATION TUTORIAL
Upload Projects to share or get help on and post the
generated links here in the forum
www.srsoft.us
Great tips, thank you very much.

Related Links

Screen is not wide enough to show the whole page the right is not showing until I scroll back and forth
Assigning cells to ranges depending on a value (image included!)
Vlookup in VBA and adding text
Outlook 2016 VBAProject.otm question
Application.GetSaveAsFilename
Comparing count in VBA
Splitting a range into to 2 ranges based on values from another range
VBA - Select Case Statement - Array
For/Next Loop not working
Using Dictionary in VBA
Changing destination sheet using VBA
VB script for Excel 2010 that will do a search for any word or phrase in my entire workbook.
Reading data from Notepad and writing into a table in Access
VBA code for saving a ppt working in debug mode,not in real run
VBA Move Paragraphs in Document Using XL
Method range of object_Worksheet failed???

Categories

MSDN
Visual FoxPro
Commerce Server
Microsoft ISV Communit...
Exchange Server
Archive
Archived Forums A-B
Archived Forums I-L
Archived Forums T-U
Archived Forums
Maps In Windows
Visual C++
Visual Studio Setup an...
Visual Studio Tools fo...
Visual Studio LightSwi...
Visual Studio LightSwi...
Testing with Visual St...
Developing Universal W...
Windows App Studio Beta
Dev Center App
Developing Windows Des...
Peer-to-Peer Networkin...
Application Security f...
Windows Desktop Search...
Windows Hardware WDK a...
Development with the W...
Windows Desktop Ribbon...
Outlook for Developers
SharePoint 2013 - Deve...
SharePoint Legacy Vers...
Azure Storage
Azure BizTalk Services
Azure Pack
Azure App Service - We...
Microsoft Azure Site R...
Azure Scripting and Co...
Azure Stream Analytics
Azure Functions
Azure Database for Pos...
Azure Time Series Insi...
The Architect Role
XML, System.Xml, MSXML...
Visual Basic for Appli...
Small Basic
SyncFx - SyncToy-File ...
SyncFx – Microsoft Syn...
Microsoft Robotics - C...
.NET Compact Framework
SQL Server Integration...
SQL Server Analysis Se...
SQL Server Replication
SQL Server High Availa...
Database Design
Standard 7: Embedded E...
SQL Server 2012 Integr...
SQL Server 2012 Spatia...
SQL Server 2012 PowerP...
SQL Server 2012 Databa...
Windows Forms General
ClickOnce and Setup & ...
Bing Maps: Map Control...
Windows Live Writer: D...
CRM Deployment
MSDN Subscriptions Fee...
Orchard –Discussions
App Linking
MSDN Magazine
Bing Maps General
Windows Protocols
Project Customization ...
Project Server - Setup...
Microsoft Unified Comm...
Microsoft Lync Server ...
Visual Studio & Silver...
Designing with Silverl...
Expression Studio
Retired SharePoint Bus...
.NET Framework 4: Wind...
.NET StockTrader Sampl...
Building Windows Store...
Building Windows Store...
CAT.NET
Core Coding Experience...
Direct3D 10
Feedback for Visual Ba...
HD DVD Interactivity A...
Innovate on Office
LINQ Project General
JScript for the .NET F...
Microsoft adCenter: De...
Microsoft Unified Comm...
Microsoft "Data Explor...
Popfly Explorer
Parallel Programming w...
Search Server: Report ...
Silverlight (formerly ...
Team Foundation Server...
Team Foundation Server...
Visual Basic Express 2...
Visual C# 2008 (Pre-re...
Visual C++ Express 200...
Visual Studio Async CTP
Visual Studio Source C...
Visual Studio Team Sys...
Visual Studio WPF/SL D...
Visual Studio Online "...
Windows CardSpace ('In...
Windows Error Reportin...
XML in Visual Studio a...
Windows Containers
Microsoft Graph

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile