Advertisement

04.30.2008 at 02:10PM PDT, ID: 23366955
[x]
Attachment Details

Type Mismatch Error VBA

Asked by npl77 in Microsoft Excel Spreadsheet Software, Visual Basic Programming

I am getting a type mismatch error when dedugging my code. I am not sure what the problem is can someone look.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
Public Sub TimelineGraph()
 
 Dim InnvationCell, StrategicCell, DevelopmentCell, RefCell, RefSACell, SATargetCell As Range
Dim Cell As Range
Dim Count As Integer
 
Do
   For Each Cell In Intersect(Sheets("CX").UsedRange, Sheets("CX").[B5:B65536])
      If Len(Cell) > 0 Then
        
          If IsEmpty(Cell) <> True Then
    
    'set the dates in the cells
    Set InnvationCell = Cell.Offset(0, 6)
    Set StrategicCell = Cell.Offset(0, 7)
    Set DevelopmentCell = Cell.Offset(0, 8)
    Set RefCell = Cell.Offset(0, 9)
    Set RefSACell = Cell.Offset(0, 10)
    Set SATargetCell = Cell.Offset(0, 11)
    
    If InnvationCell.Value <> "" & StrategicCell.Value <> "" Then
        'TYPE MISMATCH ERROR
        Call CreateBar(CDate(InnvationCell.Value), CDate(StrategicCell.Value), 45)
    End If
    
    If DevelopmentCell.Value <> "" & StrategicCell.Value <> "" Then
        Call CreateBar(CDate(StrategicCell.Value), CDate(DevelopmentCell.Value), 6)
    End If
    
    If DevelopmentCell.Value <> "" & RefCell.Value <> "" Then
        Call CreateBar(CDate(DevelopmentCell.Value), CDate(RefCell.Value), 5)
    End If
    
    If RefSACell.Value <> "" & RefCell.Value <> "" Then
        Call CreateBar(CDate(RefCell.Value), CDate(RefSACell.Value), 4)
    End If
    
    If RefSACell.Value <> "" & SATargetCell.Value <> "" Then
        Call CreateBar(CDate(RefSACell.Value), CDate(SATargetCell.Value), 39)
    End If
    
    If SATargetCell.Value <> "" Then
    
    End If
    
    
    End If
       
      
         'Cell.Offset(0, 3) = Cell
         Count = 0
      Else
         Count = Count + 1
         If Count >= 3 Then Exit Do
      End If
   Next Cell
   Exit Do
Loop
End Sub
 
Public Sub CreateBar(ByVal startDate As Date, ByVal endDate As Date, ByVal color As Integer)
 
 startDate = startDate - (Weekday(startDate, vbMonday) - 1)
 
 endDate = endDate + (7 - Weekday(endDate, vbMonday))
 With Sheets("C").Range("D2:EY2")
  .FormatConditions.Delete
  .FormatConditions.Add xlCellValue, xlBetween, startDate, endDate
  
  .FormatConditions(1).Interior.ColorIndex = color 'green
  
 End With
 
End Sub
[+][-]04.30.2008 at 02:13PM PDT, ID: 21474595

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Excel Spreadsheet Software, Visual Basic Programming
Sign Up Now!
Solution Provided By: zorvek
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628