Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Visual Basic Error Run Time Error, Type Mismatch | Excel Discussion (Misc queries) | |||
runtime error 13 - type mismatch error in Excel 97 on Citrix | Excel Programming | |||
simple: type mismatch | Excel Programming | |||
Help: Compile error: type mismatch: array or user defined type expected | Excel Programming | |||
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error | Excel Programming |