Excel - how to update/refresh cells when minor change made to a string value in a VBA function (3 Viewers)

essaytee

Need a good one-liner.
Local time
Today, 14:23
Joined
Oct 20, 2008
Messages
516
I'm working on an Excel sheet, have created many functions that return strings to the cell(s). After applying all the VBA functions to the cells (1,000's), if I make a slight change to a string within a VBA function that obviously changes the return string to the cell, how can I automatically refresh/update all the cells?

Clicking the 'Calculate Now' or 'Calculate Sheet' buttons does not work for VBA functions.

My work-around so far is to re-enter the functions, and dragging them down the rows, surely there is an easier way.

Is there an easier way?
 
Can you post here a 'before' and 'after' of a VBA function that you change so we can understand exactly what you mean, and also an example of a cell formula containing the function.

I ask because it's hard to imagine why you would need to update the cell references at all - you'd think a change within the function would update the cell values automatically
 
In a cell I have the following: It's a simple example.

=WriteExhibit(A5, A6, A7)

Code:
Function WriteExhibit(strDoc as string, datDate as Date, strRequestedBy as string) as string
   Dim strReturn as string
   strReturn = "The following document is: " & strDoc & " created on " & datDate & " and requested by " & strRequestedBy
   WriteExhibit = strReturn

End Function
The function works as intended. I apply it to 100's of rows, all correct.

So when I modify the function by changing a hardcoded part of the string from:
Code:
strReturn = "The following document is: " & ........
to:
Code:
strReturn = "The next document is: & ........

The cells are not updated.
 
Just a thought... are you perhaps changing only the code and not triggering any change on the worksheet?
 

Users who are viewing this thread

Back
Top Bottom