Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default How to make a function in a cell update

I have a worksheet with cells that contain the count of the number of files
in a particular folder as defined by "=countfiles(H3)", where H3 equals the
name of the folder I want to count files in. The countfiles function looks
like this:

Function countfiles(ByVal foldername As String)

With Application.FileSearch
.LookIn = "S:\Security" & foldername
.FileType = msoFileTypeWordDocuments
.Execute
countfiles = .FoundFiles.Count
End With

End Function

It works just fine, but the problem comes in when the count in one of those
folder is changed in some way...The cell with the formula in it that refers
to the folder where the count changed doesn't update to reflect the new
count. How can I get these functions to "refresh" or "recalculate"? I've
tried closing and reopening the spreadsheet, but that doesn't work. I've
tried going to Data---!Refresh Data, but that option is grayed out.

Any ideas?

-Brian


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to make a function in a cell update

You can add:

application.volatile

to the top of your routine--and your function will recalculate when excel
recalculates. I don't know if this will be a problem for you.

If you use that function lots of times, it could slow down the calculation.

And if something changes in that folder and you don't do anything in excel that
causes it to recalc, then the results of this function won't be up to date.

Brian Beck wrote:

I have a worksheet with cells that contain the count of the number of files
in a particular folder as defined by "=countfiles(H3)", where H3 equals the
name of the folder I want to count files in. The countfiles function looks
like this:

Function countfiles(ByVal foldername As String)

With Application.FileSearch
.LookIn = "S:\Security" & foldername
.FileType = msoFileTypeWordDocuments
.Execute
countfiles = .FoundFiles.Count
End With

End Function

It works just fine, but the problem comes in when the count in one of those
folder is changed in some way...The cell with the formula in it that refers
to the folder where the count changed doesn't update to reflect the new
count. How can I get these functions to "refresh" or "recalculate"? I've
tried closing and reopening the spreadsheet, but that doesn't work. I've
tried going to Data---!Refresh Data, but that option is grayed out.

Any ideas?

-Brian


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using an offset formula for the reference in a relative reference Cuda Excel Worksheet Functions 6 November 15th 06 05:12 PM
How to make IF function not change cell value? SE Excel Worksheet Functions 2 October 27th 06 03:51 AM
How to Enter data and Function in same cell [email protected] Excel Discussion (Misc queries) 3 October 2nd 06 07:10 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
Function syntax to compare cell contents ES Excel Worksheet Functions 2 May 18th 05 03:53 PM


All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"