Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 187
Default type 13 error

The following UDF gives a type 13 error when using XL 2007:

Function SetTemp1(Temp, Temp1)
Dim ss As String
If Temp = Temp1 Then ' Constant not a number
SetTemp1 = Temp
ElseIf Val(Temp) = Temp1 Then 'constant number
SetTemp1 = Temp1 * 2
Else ' Formula
ss = Temp
If Left(ss, 1) = "=" Then ss = Right(ss, Len(ss) - 1)
SetTemp1 = "=(" & ss & ")*2"
End If
End Function

The debugger highlights If Temp = Temp1 Then ' Constant not a
number
as causing the error.

I received this workbook from someone else, so I'm not too clear on
what this UDF is supposed to do or what is causing the error.

Thoughts?

Dave

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 187
Default type 13 error

This is interesting. I copied the code below, inserted it into a
module in a completely new workbook, entered the function, and there
was no error!

Wonder what could have caused the error in the original workbook?

On Nov 2, 7:39 pm, Dave F wrote:
The following UDF gives a type 13 error when using XL 2007:

Function SetTemp1(Temp, Temp1)
Dim ss As String
If Temp = Temp1 Then ' Constant not a number
SetTemp1 = Temp
ElseIf Val(Temp) = Temp1 Then 'constant number
SetTemp1 = Temp1 * 2
Else ' Formula
ss = Temp
If Left(ss, 1) = "=" Then ss = Right(ss, Len(ss) - 1)
SetTemp1 = "=(" & ss & ")*2"
End If
End Function

The debugger highlights If Temp = Temp1 Then ' Constant not a
number
as causing the error.

I received this workbook from someone else, so I'm not too clear on
what this UDF is supposed to do or what is causing the error.

Thoughts?

Dave



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default type 13 error

You possibly have Temp defined elsewhere in the module as a constant with a
numerical value. In your original workbook, that is.

"Dave F" wrote:

This is interesting. I copied the code below, inserted it into a
module in a completely new workbook, entered the function, and there
was no error!

Wonder what could have caused the error in the original workbook?

On Nov 2, 7:39 pm, Dave F wrote:
The following UDF gives a type 13 error when using XL 2007:

Function SetTemp1(Temp, Temp1)
Dim ss As String
If Temp = Temp1 Then ' Constant not a number
SetTemp1 = Temp
ElseIf Val(Temp) = Temp1 Then 'constant number
SetTemp1 = Temp1 * 2
Else ' Formula
ss = Temp
If Left(ss, 1) = "=" Then ss = Right(ss, Len(ss) - 1)
SetTemp1 = "=(" & ss & ")*2"
End If
End Function

The debugger highlights If Temp = Temp1 Then ' Constant not a
number
as causing the error.

I received this workbook from someone else, so I'm not too clear on
what this UDF is supposed to do or what is causing the error.

Thoughts?

Dave




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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
xpath error? Runtime Error 13 type mismatch SteveM Excel Discussion (Misc queries) 1 December 4th 07 09:16 AM
Conditional Formatting - Run Time Error '13' Type Mismatch Error ksp Excel Programming 0 July 11th 06 07:06 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM


All times are GMT +1. The time now is 06:12 PM.

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"