LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Value# in VBA script with reference

Hi,

I'm not a specialist in VBA, but also not a newbee (I think).
I try to get the contence of a cell from a different worksheet but I
get the message: VALUE#
(A value used in the formula is of the wrong data type). What am I
doing wrong!
Below the function.

Function CalcValue(pVal) As Long

If pVal = 1 Then
CalcValue = wegingsfactoren!D3

ElseIf pVal = 2 Then
CalcValue = wegingsfactoren!D4

ElseIf pVal = 3 Then
CalcValue = wegingsfactoren!D5

ElseIf pVal = 4 Then
CalcValue = wegingsfactoren!D6

ElseIf pVal = 5 Then
CalcValue = wegingsfactoren!D7

ElseIf pVal = 6 Then
CalcValue = wegingsfactoren!D8

ElseIf pVal = 7 Then
CalcValue = wegingsfactoren!D9

ElseIf pVal = 8 Then
CalcValue = wegingsfactoren!D10

ElseIf pVal = 9 Then
CalcValue = wegingsfactoren!D11

ElseIf pVal = 10 Then
CalcValue = wegingsfactoren!D12

ElseIf pVal = 11 Then
CalcValue = wegingsfactoren!D13

ElseIf pVal = 12 Then
CalcValue = wegingsfactoren!D14

ElseIf pVal = 13 Then
CalcValue = wegingsfactoren!D15

ElseIf pVal = 14 Then
CalcValue = wegingsfactoren!D16

ElseIf pVal = 15 Then
CalcValue = wegingsfactoren!D17

ElseIf pVal = 16 Then
CalcValue = wegingsfactoren!D18

ElseIf pVal = 17 Then
CalcValue = wegingsfactoren!D19

ElseIf pVal = 18 Then
CalcValue = wegingsfactoren!D20

Else
CalcValue = 0
End If

End Function

Thanks

Theo Vermeer

 
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
VBA script Gor_yee Excel Discussion (Misc queries) 1 April 28th 09 10:43 AM
HOWTO Reference a named cell or range in a script pwrichcreek Excel Discussion (Misc queries) 2 September 1st 08 06:13 AM
Help with the script Angela[_2_] Excel Discussion (Misc queries) 1 March 22nd 08 10:36 PM
Script to locate unique reference help please Peter[_28_] Excel Programming 0 November 15th 04 07:13 PM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM


All times are GMT +1. The time now is 12:01 AM.

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"