Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default CDbl and "Type mismatch"

Neither of these cases work. I just get a "Type mismatch" error.

Dim deg(10), min(10), sec(10), DEGt(10) as Double

deg(h) = CDbl(.Cells(2 + h, 3))
min(h) = CDbl(.Cells(2 + h, 4))
sec(h) = CDbl(.Cells(2 + h, 5))
DEGt(h) = deg(h) + min(h))/ 60 + sec(h) / 3600
or
deg(h) = .Cells(2 + h, 3)
min(h) = .Cells(2 + h, 4)
sec(h) = .Cells(2 + h, 5))
DEGt(h) = CDbl(deg(h)) + CDbl(min(h)) / 60 + CDbl(sec(h)) / 3600
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default CDbl and "Type mismatch"

I'm guessing "h" is a loop variable... what values does it iterate over?
Also, **exactly** what is in your cells that you are trying to convert (show
us an example or two)? Also, I see a "dot" in front of the Cells call...
what is it having the cell refer back to?

--
Rick (MVP - Excel)



"Philosophaie" wrote in message
...
Neither of these cases work. I just get a "Type mismatch" error.

Dim deg(10), min(10), sec(10), DEGt(10) as Double

deg(h) = CDbl(.Cells(2 + h, 3))
min(h) = CDbl(.Cells(2 + h, 4))
sec(h) = CDbl(.Cells(2 + h, 5))
DEGt(h) = deg(h) + min(h))/ 60 + sec(h) / 3600
or
deg(h) = .Cells(2 + h, 3)
min(h) = .Cells(2 + h, 4)
sec(h) = .Cells(2 + h, 5))
DEGt(h) = CDbl(deg(h)) + CDbl(min(h)) / 60 + CDbl(sec(h)) / 3600


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default CDbl and "Type mismatch"

for h = 1 to 23
...
next h

deg(1)=20
min(1)=45
sec(1)=21
DEGt(1)=20.755833333
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default CDbl and "Type mismatch"

I'm not entirely sure why you are getting a "Type Mismatch" error, at least
not with the code fragment you showed us (maybe the error is occurring
elsewhere in your code), but your array limits are wrong. You showed this in
your code...

Dim deg(10), min(10), sec(10), DEGt(10) as Double


and you just told me this...

for h = 1 to 23


so when "h" hits 11, there will be a problem as your array is not big enough
to hold that index value (but I would not expect a "Type Mismatch" error to
be occurring for it). Perhaps if you post all of your code (copy/paste it,
don't retype it as I see some mistyping in the code you posted originally).

--
Rick (MVP - Excel)



"Philosophaie" wrote in message
...
for h = 1 to 23
...
next h

deg(1)=20
min(1)=45
sec(1)=21
DEGt(1)=20.755833333


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
Avoid Type Mismatch Error when using CDBL() ExcelMonkey Excel Programming 3 May 13th 09 07:51 PM
"Type mismatch" when I try to fill an Array variable with "+" [email protected] Excel Discussion (Misc queries) 1 April 17th 07 01:28 PM
Error Handling to mitigate "Run Time Erorr 13 Type Mismatch" ExcelMonkey Excel Programming 3 October 16th 05 01:56 PM
"FIND" generates "Type mismatch" error quartz[_2_] Excel Programming 5 November 16th 04 03:29 PM


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