how to do live update or synchronized in vba - vba

how to do live updates to one cell to another cell?? I don't know, is it call synchronized or live updates, what im trying to do, i want my cell to update to another sheet, if i change something or values in sheet1 cell 1 then sheet2 cell 1 should change it automatically.. any1 have any ideas ????do i have to do live change or live updates or its a synchronizing or how do i code it, i never did anything like that before.....
sub worksheet_change()
if sheets("sheet1") = sheets("sheet2") then
do liveupdate
end if
end sub

DDE
If it's on the same computer, you can do something called DDE and make DDE based functions.
DDE is an old but still very well used technology (especially in the financial industry) which stands for Dynamic Data Exchange. That will enable you to control values in the cells of one worksheet from code driven through another.
Search for DDE examples, DDE MSDN, etc. and you'll find tonnes of simple examples out there.
DCOM ??
For a while, MSFT wanted to extend DDE and similar technologies across networks, like Distributed COM but security issues got in the way and common sense prevailed.
RTD:
A bit more involved and better (IMHO) method is creating a simple RTD server (Real Time Data Server) that reads data from your sheet, and pumps it across a network or simply to another instance of Excel on your computer.
Either of these methods can be used to distribute live stock feeds, etc. coming onto expensive subscription terminals across a network (be aware of the licensing issues though for spreading any data around using these techniques).
RTD information can also be found with simple examples to set up an RTD server scattered across google search results.
Hope it was helpful.

Related

Google Sheets API Timing Out

I currently have a very heavy Google Sheets workbook with about 8 sheets, thousands of rows, and complex formulas. We use this a source file for many tasks and link to this workbook from several other Google Sheets using Import Range and a 3rd party tool called Coupler.IO.
This week, the ImportRanges and Coupler Imports all started timing out and would not finish. Nothing has been changed in the source file except some minor additions of data.
This seems to be an API or Google Server Bandwidth problem, but there's really no way to confirm.
Is anyone else having similar issues? Is there a solve out there?
-Leo

Automatically pull baseball statistics from web to worksheet

I would like to pull data on daily Major League Baseball statistics to an excel spreadsheet. The data will come from this website.
I would like to pull each day of stats to it's own sheet in the excel workbook. I would also like this process to be automated, so when the stats for future days are released they will also be pulled to a new sheet.
I am running Excel 2011 on a Mac.
You haven't provided anything for us to go on. Do you need help getting started?
I don't know if this is applicable to the mac environment, but in Windows, you can use a COM reference to get excel to automate internet explorer. IE isn't the best browser, but for most automation tasks, it works well enough, and the COM reference makes it easy. If that doesn't work for you, check out Selenium:
http://code.google.com/p/selenium-vba/
Side-note: I'm not sure what you're planning on doing with the stats, but I wouldn't want to mess with a workbook laid out that way. You might be better writing a script to get it all into a database.

mimic bdh function fill down

When a query is entered into the Bloomberg BDH function in Excel it automatically populates the selected cell, and cells below with the requested data.
I am trying to create a function that does something similar (albeit with a different source of data). How does the BDH function circumvent the typical restriction within a user defined function of modifying other cells when it fills down the queried data?
You need to do it in a two-stage process:
Your function calls another process to compute values and return only the 1st element of the array to be returned (could be "#NA #NA" or the date or price, etc.
The called process can be running in a separate RTD server (check out Real Time Data server) or a separate process which links to your spreadsheet via DDE. (Bloomberg uses DDE for some functions, RTD for the others, I think)
That way when you call a function, the first value is returned immediately (i.e. the answer, or "#NA Requesting Data..." and then when the RTD server fetches the required data the answer to this function changes to whatever the top-left array element is, and the rest of the cells are populated via DDE/RTD.
Simple examples of setting up a RTD server are found on Microsoft's knowledge base. Also, lots of examples using DDE (an older, but very popular technology for financial data exchange using Excel, even today) are available upon Googling.
A simple filler application can be built using C# or VB.net Interop (search again for examples).
Hope this helps.
Edit: You can also do this completely using VBA by using some clever combination of the OnTime functionality (see http://www.cpearson.com/excel/OnTime.aspx) and combining it with DDE driven from a separate spreadsheet (look up Tushar Mehta DDE clock, a very old example, but some things never change!)

Is there any way to block a workbook from "external" access?

first time asking something here, so I'll apologize beforehand in case I do anything I shouldn't do.
I'm working on a workbook and there are some information in it that shouldn't be available to everyone else, save a few users.
While doing some testing around I've found that it was possible to use another instance of Excel, i.e. another workbook, to access that information (in this case, using VBA).
What I want to know is: is it possible to block another instance of Excel or another workbook from accessing this workbook with the information I want to protect?
The point of this sheet in working on is to be used as a 'database' of sorts for performance feedback of other employees. They fill a form with their self evaluation and then their manager also fill it, evaluating them. All this is stored in a sheet, which is hidden (veryhidden, to be more specific). Using a simple login system, I was able to enable access to this sheet to only one user (one with admin privileges), but assuming someone knows the existence of that sheet, it would be perfectly possible for them to, for example, just copy everything from that sheet to a blank sheet in a new workbook.
Ultimately, what I'm trying to achieve is some kind of restriction in this workbook, allowing only it's own subs and functions to work on it
Thanks in advance
EDIT: Added some info. Hope that helped clarify my problem
The only way to achieve this is encryption. As far as I know Excel only supports one form of encryption, full workbook encryption. In that case there is a password to open the workbook, a user either has access to the full workbook or none at all.
Any other form of encryption in Excel, protected cells, passwords on macros, etc. can all be bypassed easily by a knowledgable user.
However, you could achieve this using either an external database server or implementing your own encryption scheme in the workbook.
There is some information here on howto access the Windows CryptoAPI from VBA.

VB - Automated Excel in Visual Studio 2010 - Selection Changed Question

I am currently writing an utility that takes two different sets of data from an excel document and sends it to two different web services. Each set of data has it's own button that sends the data to the web service. When the a button is clicked, the corresponding web service then returns data depending on the input values.
What I am trying to do is so that this utility can be distrobuted and used by a wide variety of people. What they are going to do is they are going to be synchronizing there particular cells of their own excel document to the corresponding cell in my utility. Using simple excel formulas. For example:
c:\temp\[book1.xls]sheet1'!a1
Now what I am trying to do is automatically "click" the button, or update, on my utility when the user links their cell to its corresponding cell on my utility.
I have tried the selection change event on my page. But it doesn't actually process until my utility is active, or clicked on.
Is there a way to make my utility automatically update? It would be especially awesome if somehow it did this while my utility was closed. So when the user opens it it is already filled with their information, and the outputs are correct.
The requirements:
you need to guarantee that when a user is using excel your app can collect the data. Your app may not be running at the time. You need the Worksheet_SelectionChange() event to fire automatically not just when your app is active.
Solution:
Basically in order to guarantee that the Worksheet_SelectionChange() is running all the time, and in order to guarantee that whenever the user opens an instance of excel you are able to collect and process the data/formulas entered into the particular target range address you need to wire up the selectionchange event inside of a VB.NET Excel COM Addin. There are several ways to do this, but since your using VB.NET your best off using the newest approach which is building a VSTO COM Addin.
There are numerous other questons available on how to best build a VSTO addin (some in C# some in VB.NET but all this information is exactly the same for both, just different syntax).
So you will need two projects. Your existing one, plus a Excel VSTO addin (which you can also do in VB.NET).
Now inside the selectionchange event you should make sure that your code handles the target range correctly; ie. make sure you check for non-contigious groups of ranges with a selection... A1:B1;D2:E2 and copy the data to your app. You may consider using a format such as xml to serialise the latest data from excel so that if your app is not open at the time, it can deserialise and read back the data stored for it the next time it is opened. I guess it really depends how your handling the data (i.e. is it for loading into a datagrid?) and whether you are going to do further processing and store it somewhere else later (in which case maybe you can put it straight into a database from the addin in excel).