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

Below is part of the code I am using. I get a "Type Mismatch" error on the
line I indicate as "<----ERROR" Why?

Basically, this routine takes the dates for paid holidays (holdate) and
compares it to the date (on active row) + 7 days. If holdate < wdate+7, then
the current cell value(cv) is pulled in. I then add the holiday hours
(holhr) to cv and reinsert it back in the spreadsheet.

DIM cv, holhr(11) as Variant "I guess this is correct Dim for ##.## format

For Each Cell In rngpc
wdate = Cell.Offset(0, -13).Value 'Get Beg of week date
For cntr = 1 To cnt - 1
cv = Cell.Value 'Get value of cell
MsgBox holdate(cntr) & " < " & wdate + 7 & " CV= " & cv
If holdate(cntr) < wdate + 7 Then
Cell.Value = cv + holhr(cntr) <======ERROR
End If
Next cntr
Next Cell

Thanks for your help!

Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Type Mismatch error

I'd check to see what CV held and what cntr held and what holhr(cntr) held.



WLMPilot wrote:

Below is part of the code I am using. I get a "Type Mismatch" error on the
line I indicate as "<----ERROR" Why?

Basically, this routine takes the dates for paid holidays (holdate) and
compares it to the date (on active row) + 7 days. If holdate < wdate+7, then
the current cell value(cv) is pulled in. I then add the holiday hours
(holhr) to cv and reinsert it back in the spreadsheet.

DIM cv, holhr(11) as Variant "I guess this is correct Dim for ##.## format

For Each Cell In rngpc
wdate = Cell.Offset(0, -13).Value 'Get Beg of week date
For cntr = 1 To cnt - 1
cv = Cell.Value 'Get value of cell
MsgBox holdate(cntr) & " < " & wdate + 7 & " CV= " & cv
If holdate(cntr) < wdate + 7 Then
Cell.Value = cv + holhr(cntr) <======ERROR
End If
Next cntr
Next Cell

Thanks for your help!

Les


--

Dave Peterson
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
Conditional Formatting - Run Time Error '13' Type Mismatch Error ksp Excel Programming 0 July 11th 06 07:06 AM
Type Mismatch Error Nicole Seibert Excel Programming 3 March 17th 06 01:40 PM
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 12:28 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"