ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range.Value fails (https://www.excelbanter.com/excel-programming/380574-range-value-fails.html)

vga1976

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


Nick Hodge

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



Trevor Shuttleworth

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




vga1976[_2_]

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


Trevor Shuttleworth

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





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com