Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default 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
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
Excel VBA Paste of Range with PrefixCharacter fails from VB.NET Nicholas Dreyer Excel Discussion (Misc queries) 0 April 6th 07 04:09 AM
Select range fails Geoff Excel Programming 6 August 16th 05 06:53 AM
select method of range class fails mark kubicki Excel Programming 12 April 27th 05 02:37 PM
Named Range Fails in VBA Code Dean Hinson[_3_] Excel Programming 3 January 24th 05 03:48 PM
Select method of Range fails J West Excel Programming 1 June 7th 04 02:41 PM


All times are GMT +1. The time now is 11:03 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"