Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Why does my Function not work?

in VBA Excel
Function GetText() As String
Dim Str1 As String
For Row = 51 To 74
Str1 = Str1 & Cells(Row, 3).Text
Next Row
GetText = Str1
End Function

in worksheet
cell C77 contains =gettext()

Now when any row 51 to 74 and column 3 changes my function gettext
does not update. Could some explain to me why and what I should do to
fix it

Thanks,

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default Why does my Function not work?

Since you don't have the range in your function's arguments, XL has no
way of knowing that cells C51 or C74 have anything to do with your
function.

You could force the function to calculate every time the sheet
calculates by including Application.Volatile at the top of your macro.

Better, you could put the range in your function's arguments:

Public Function GetText(byRef rng As Excel.Range) As String
Dim rCell As Range
Dim sTemp As String

For Each rCell in rng
sTemp = sTemp & rCell.Text
Next rCell
GetText = sTemp
End Function

Then

C77: =GetText(C51:C74)




In article .com,
wrote:

in VBA Excel
Function GetText() As String
Dim Str1 As String
For Row = 51 To 74
Str1 = Str1 & Cells(Row, 3).Text
Next Row
GetText = Str1
End Function

in worksheet
cell C77 contains =gettext()

Now when any row 51 to 74 and column 3 changes my function gettext
does not update. Could some explain to me why and what I should do to
fix it

Thanks,

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Why does my Function not work?

Make it volatile.

Function GetText() As String
Application.Volatile True
Dim Str1 As String
For Row = 51 To 74
Str1 = Str1 & Cells(Row, 3).Text
Next Row
GetText = Str1
End Function


Gord Dibben MS Excel MVP

On 27 Apr 2007 14:03:08 -0700, wrote:

in VBA Excel
Function GetText() As String
Dim Str1 As String
For Row = 51 To 74
Str1 = Str1 & Cells(Row, 3).Text
Next Row
GetText = Str1
End Function

in worksheet
cell C77 contains =gettext()

Now when any row 51 to 74 and column 3 changes my function gettext
does not update. Could some explain to me why and what I should do to
fix it

Thanks,


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
Why won't th unhide function work?? Draino Excel Discussion (Misc queries) 7 March 13th 07 02:01 PM
NETWORKDAYS Function doesn't work Dean Excel Worksheet Functions 4 July 23rd 06 03:50 PM
how do i get the mid function to work with a zero garbold Excel Worksheet Functions 7 June 7th 06 10:58 PM
Which excel function would work best? Paul T Excel Worksheet Functions 1 March 1st 06 07:19 PM
Why doesn't my =RANDBETWEEN function work? DanielWalters6 Excel Discussion (Misc queries) 4 December 19th 05 10:28 AM


All times are GMT +1. The time now is 11:03 PM.

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

About Us

"It's about Microsoft Excel"