Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft Excel - Refreshing Formulas

Status
Not open for further replies.

EliseFreedman

Programmer
Dec 6, 2002
470
GB
Hi there

I am compiling a report in Excel consisting of medical appointment statistics. The stats come from various different queries obtained from our software (Not microsoft). Basically I have to run the queries in the Costar software, save the output as text files and then import the files into different spreadsheets within the stats workbook. As this report is going to be updated on a monthly basis by colleagues, i am trying to automate it. It is easy enough to automate the importing of files into excel. Before i started to write the macro, i copied all the formulas over so that there are formulas in for the remaining months of the year. I then imported the first couple of queries. This is where i have hit a problem. The formulas are not updating to reflect the changes in data. In order to get them to update, I am having to click on each of the cells that I want to update, hit F2 and then enter. They then update to show the new values. I would prefer them to update immediately. I have checked and calculation is set to automatic. Does anyone have any ideas?
 
Two options come to mind:

[tab]1) calculation set to manual
Go to Tools > Options > Calculate. Set it Automatic.

FYI: When in Manual, [F9] will force the entire spreadsheet to calculate.

[tab]1) Cells are formatted as text
What do the cells currently show? Do they show the actual formula rather than a value?


[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
BTW, if you need help with the actual macro, please create a new thread for your VBA/Macro-specific question in forum707

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 



I noticed that you stated that Automatic is on.

"I am having to click on each of the cells that I want to update,..."

Calculate each range...
Code:
TheRange.Calculate


Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Heh. I totally missed that in the OP somehow.

Note to self: must read slower.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
and check this out...

Calculations may not occur in an Excel workbook that has many formulas when you use the Calculate method to calculate formulas or after you press SHIFT+F9 to calculate formulas


Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Well cover me with grits and call me breakfast....

I still think it would be helpful to know what the cells are currently displaying, though. Especially since we are dealing with imported data from another application.

A common scenario goes like this:
-Import data
-Insert a column for formulas
-cells just display the formulas rather than the answer

The problem is that the inserted column took on the properties of the column to the left, which was formatted as text. You can select the column, change the format from text to general - or even number or date - but nothing happens.

Pressing F2 (or double clicking into a cell) then pressing Enter works, but you don't want to do that for every single cell.

When dealing with this on the fly, I usually just use the "Times 1 Fix", which I'll outline below.

Another fix is to use Data > Text to columns, fixed width, no breaks, then choose General for the column.

Since you're doing all this in code, you can simply use the following:
Code:
[A:A].value = [A:A].value

Times 1 Fix:
[ul][li]In a cell to the right of all the imported data, type [blue]1[/blue][/li]
[ul][li](this should be right-aligned, indicating that the cell is formatted as a number)[/li][/ul]
[li]copy that cell[/li]
[li]select the cells that are giving you trouble[red]*[/red][/li]
[li]Go to Edit > Paste Special > Multiply[/li]
[li]Now try applying a new format to those cells [/li][/ul]

Hope something in there helps....

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top