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

I want to run several consective tests on "curcell". Select case seemed less
messy than nested if-then. However I am getting the above error on the **
line. Help appreciated


Dim curcell As Range
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets

For Each curcell In sht.UsedRange.Cells

Select Case curcell.Column
Case Is < 1
Select Case curcell.Row
Case Is < 1
Select Case TypeName(curcell.Offset(-1, 0))
**Case Is = "String" Or "Date"
Select Case TypeName(curcell.Offset(0, -1))
Case Is = "String" Or "Date"
Select Case curcell.Offset(-1, 0).Value
Case Is < 2002 Or 2003 Or 2004 Or 2005 Or 2006 Or 2007 _
Or 2008 Or 2009
MsgBox curcell.Address
Exit For
End Select
End Select
End Select
End Select
End Select

Next curcell

Next sht
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default probably simple - type mimatch error 13

First, I think you have a couple of problems:

Case Is = "String", "Date"
(in multiple locations.)

And second, I bet you want:

Select Case TypeName(curcell.Offset(-1, 0).Value)
Case Is = "String", "Date"

If you use:
Select Case TypeName(curcell.Offset(-1, 0))
without the .value, then typename() will always return Range.



PBcorn wrote:

I want to run several consective tests on "curcell". Select case seemed less
messy than nested if-then. However I am getting the above error on the **
line. Help appreciated

Dim curcell As Range
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets

For Each curcell In sht.UsedRange.Cells

Select Case curcell.Column
Case Is < 1
Select Case curcell.Row
Case Is < 1
Select Case TypeName(curcell.Offset(-1, 0))
**Case Is = "String" Or "Date"
Select Case TypeName(curcell.Offset(0, -1))
Case Is = "String" Or "Date"
Select Case curcell.Offset(-1, 0).Value
Case Is < 2002 Or 2003 Or 2004 Or 2005 Or 2006 Or 2007 _
Or 2008 Or 2009
MsgBox curcell.Address
Exit For
End Select
End Select
End Select
End Select
End Select

Next curcell

Next sht


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default probably simple - type mimatch error 13

On Oct 29, 10:13 am, PBcorn wrote:
I want to run several consective tests on "curcell". Select case seemed less
messy than nested if-then. However I am getting the above error on the **
line. Help appreciated

Dim curcell As Range
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets

For Each curcell In sht.UsedRange.Cells

Select Case curcell.Column
Case Is < 1
Select Case curcell.Row
Case Is < 1
Select Case TypeName(curcell.Offset(-1, 0))
**Case Is = "String" Or "Date"
Select Case TypeName(curcell.Offset(0, -1))
Case Is = "String" Or "Date"
Select Case curcell.Offset(-1, 0).Value
Case Is < 2002 Or 2003 Or 2004 Or 2005 Or 2006 Or 2007 _
Or 2008 Or 2009
MsgBox curcell.Address
Exit For
End Select
End Select
End Select
End Select
End Select

Next curcell

Next sht


replace the 'or' with ','
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default probably simple - type mimatch error 13

Thanks. that worked. However i now find i have values 2004,2005,2006 etc
which are numbers, and not recognised as dates. so i tried case =
"string","date", 2003,2004,2005,2006 but this does not pick up these values.
please advise

"Dave Peterson" wrote:

First, I think you have a couple of problems:

Case Is = "String", "Date"
(in multiple locations.)

And second, I bet you want:

Select Case TypeName(curcell.Offset(-1, 0).Value)
Case Is = "String", "Date"

If you use:
Select Case TypeName(curcell.Offset(-1, 0))
without the .value, then typename() will always return Range.



PBcorn wrote:

I want to run several consective tests on "curcell". Select case seemed less
messy than nested if-then. However I am getting the above error on the **
line. Help appreciated

Dim curcell As Range
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets

For Each curcell In sht.UsedRange.Cells

Select Case curcell.Column
Case Is < 1
Select Case curcell.Row
Case Is < 1
Select Case TypeName(curcell.Offset(-1, 0))
**Case Is = "String" Or "Date"
Select Case TypeName(curcell.Offset(0, -1))
Case Is = "String" Or "Date"
Select Case curcell.Offset(-1, 0).Value
Case Is < 2002 Or 2003 Or 2004 Or 2005 Or 2006 Or 2007 _
Or 2008 Or 2009
MsgBox curcell.Address
Exit For
End Select
End Select
End Select
End Select
End Select

Next curcell

Next sht


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default probably simple - type mimatch error 13

sorry to confuse you. the original code was wrong, the <2003,2004,2005..
should have been = 2003,2004,2005,2006...




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default probably simple - type mimatch error 13

Maybe you could use:

Case Is = "String", "Date", "Double"

ps. I find this easier to read:

Select Case curcell.Offset(-1, 0).Value
Case 2004 To 2009
'do nothing
Case Else
'do the real work
MsgBox curcell.Address
Exit For
End Select

PBcorn wrote:

Thanks. that worked. However i now find i have values 2004,2005,2006 etc
which are numbers, and not recognised as dates. so i tried case =
"string","date", 2003,2004,2005,2006 but this does not pick up these values.
please advise

"Dave Peterson" wrote:

First, I think you have a couple of problems:

Case Is = "String", "Date"
(in multiple locations.)

And second, I bet you want:

Select Case TypeName(curcell.Offset(-1, 0).Value)
Case Is = "String", "Date"

If you use:
Select Case TypeName(curcell.Offset(-1, 0))
without the .value, then typename() will always return Range.



PBcorn wrote:

I want to run several consective tests on "curcell". Select case seemed less
messy than nested if-then. However I am getting the above error on the **
line. Help appreciated

Dim curcell As Range
Dim sht As Worksheet

For Each sht In ActiveWorkbook.Worksheets

For Each curcell In sht.UsedRange.Cells

Select Case curcell.Column
Case Is < 1
Select Case curcell.Row
Case Is < 1
Select Case TypeName(curcell.Offset(-1, 0))
**Case Is = "String" Or "Date"
Select Case TypeName(curcell.Offset(0, -1))
Case Is = "String" Or "Date"
Select Case curcell.Offset(-1, 0).Value
Case Is < 2002 Or 2003 Or 2004 Or 2005 Or 2006 Or 2007 _
Or 2008 Or 2009
MsgBox curcell.Address
Exit For
End Select
End Select
End Select
End Select
End Select

Next curcell

Next sht


--

Dave Peterson


--

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
runtime error 13 - type mismatch error in Excel 97 on Citrix Kevin Maher Excel Programming 7 March 8th 08 11:48 AM
simple: type mismatch mark kubicki Excel Programming 1 February 21st 06 07:01 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 01:48 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"