Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range.Value fails
I have a function that wrote the result on a Range using its propert Value. The function works fine when I test it in VBA, I mean the resul is wrote correctly on the range. But the function fails when I used i on the worksheet as a cell's formula, it fails at the line when assign the result to the range using its property Value. Could you help me to fix this problem? Regard -- vga197 ----------------------------------------------------------------------- vga1976's Profile: http://www.officehelp.in/member.php?userid=568 View this thread: http://www.officehelp.in/showthread.php?t=131053 Posted from - http://www.officehelp.i |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range.Value fails
Post your code as you have it
Remember you do not assign back to the range.value you simply use the function name to return the value. e.g Function myFunc(Input as Double) As Double myFunc=Input*2 End Function -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England DTHIS www.nickhodge.co.uk "vga1976" wrote in message ... I have a function that wrote the result on a Range using its property Value. The function works fine when I test it in VBA, I mean the result is wrote correctly on the range. But the function fails when I used it on the worksheet as a cell's formula, it fails at the line when I assign the result to the range using its property Value. Could you help me to fix this problem? Regards -- vga1976 ------------------------------------------------------------------------ vga1976's Profile: http://www.officehelp.in/member.php?userid=5683 View this thread: http://www.officehelp.in/showthread.php?t=1310532 Posted from - http://www.officehelp.in |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range.Value fails
please post the code
"vga1976" wrote in message ... I have a function that wrote the result on a Range using its property Value. The function works fine when I test it in VBA, I mean the result is wrote correctly on the range. But the function fails when I used it on the worksheet as a cell's formula, it fails at the line when I assign the result to the range using its property Value. Could you help me to fix this problem? Regards -- vga1976 ------------------------------------------------------------------------ vga1976's Profile: http://www.officehelp.in/member.php?userid=5683 View this thread: http://www.officehelp.in/showthread.php?t=1310532 Posted from - http://www.officehelp.in |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range.Value fails
Sorry, this is the code Function PutVectorInRange(vector As Variant, xlWs As Excel.Worksheet iCol As Integer, lRow As Long) As Boolean Dim xlRange As Excel.Range Dim lSize As Long, vColVector As Variant If Not IsEmpty(vector) Then lSize = UBound(vector, 1) - LBound(vector, 1) Set xlRange = xlWs.Range(xlWs.Cells(lRow, iCol), xlWs.Cells(lRow lSize, iCol)) 'convert the row vector to column vector vColVector = DepConvertRowVectToColVect(vector) xlRange.Value = vColVector End If End Functio -- vga197 ----------------------------------------------------------------------- vga1976's Profile: http://www.officehelp.in/member.php?userid=568 View this thread: http://www.officehelp.in/showthread.php?t=131053 Posted from - http://www.officehelp.i |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range.Value fails
A function can only return a value. In this case, PutVectorInRange should
return a value of True or False as you have defined it as Boolean. However, you don't actually set the value of the function anywhere within the function. You cannot set/change the value in another cell or range within a function. Regards Trevor "vga1976" wrote in message ... Sorry, this is the code Function PutVectorInRange(vector As Variant, xlWs As Excel.Worksheet, iCol As Integer, lRow As Long) As Boolean Dim xlRange As Excel.Range Dim lSize As Long, vColVector As Variant If Not IsEmpty(vector) Then lSize = UBound(vector, 1) - LBound(vector, 1) Set xlRange = xlWs.Range(xlWs.Cells(lRow, iCol), xlWs.Cells(lRow + lSize, iCol)) 'convert the row vector to column vector vColVector = DepConvertRowVectToColVect(vector) xlRange.Value = vColVector End If End Function -- vga1976 ------------------------------------------------------------------------ vga1976's Profile: http://www.officehelp.in/member.php?userid=5683 View this thread: http://www.officehelp.in/showthread.php?t=1310532 Posted from - http://www.officehelp.in |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel VBA Paste of Range with PrefixCharacter fails from VB.NET | Excel Discussion (Misc queries) | |||
Select range fails | Excel Programming | |||
select method of range class fails | Excel Programming | |||
Named Range Fails in VBA Code | Excel Programming | |||
Select method of Range fails | Excel Programming |