skull_eagle
Board Regular
- Joined
- Mar 25, 2011
- Messages
- 89
Hi Everyone,
I need to run some code with a large amount of variables.
When running the below code, it runs "Line 1" and "Line 2" code no problem as soon as it hits the "Line 3" code it gives me a Type mismatch error on every line of code that contains a 'Time(?,?,?)' statement.
If it has already run these statements in "Line 1" and "Line 2" code I can't see why it would be having issues in the "Line 3" area.
Any help would be greatly appreciated.
(I apologise for the large amount of code)
[face=Courier New]
[/face]
Thanks
I need to run some code with a large amount of variables.
When running the below code, it runs "Line 1" and "Line 2" code no problem as soon as it hits the "Line 3" code it gives me a Type mismatch error on every line of code that contains a 'Time(?,?,?)' statement.
If it has already run these statements in "Line 1" and "Line 2" code I can't see why it would be having issues in the "Line 3" area.
Any help would be greatly appreciated.
(I apologise for the large amount of code)
[face=Courier New]
Code:
[color=darkblue]Do[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -15) = "On-site" [color=darkblue]Then[/color] [color=darkblue]GoTo[/color] Line1 [color=darkblue]Else[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -15) = "Creation" [color=darkblue]Then[/color] [color=darkblue]GoTo[/color] Line2 [color=darkblue]Else[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -15) = "Off-site" [color=darkblue]Then[/color] [color=darkblue]GoTo[/color] Line3
Line1:
[color=darkblue]If[/color] ActiveCell.Offset(0, -13) = "Sat/Sun" [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=RC[-2]-TIME(8,0,0)"
[color=darkblue]If[/color] ActiveCell.Offset(0, -1) = 0 [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) >= Time(8, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=RC[-2]-RC[-12]"
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) < Time(8, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=(RC[-2]-RC[-12])+(TIME(8,0,0)-RC[-12])"
[color=darkblue]If[/color] ActiveCell.Offset(0, -1) >= 1 [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) > Time(18, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=RC[-2]-TIME(8,0,0)"
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) <= Time(18, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=(TIME(18,0,0)-RC[-12])+(RC[-2]-TIME(8,0,0))"
[color=darkblue]GoTo[/color] Line4
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
Line2:
[color=darkblue]If[/color] ActiveCell.Offset(0, -13) = "Sat/Sun" [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=RC[-2]-TIME(8,0,0)"
[color=darkblue]If[/color] ActiveCell.Offset(0, -1) = 0 [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) >= Time(8, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=RC[-2]-RC[-12]"
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) < Time(8, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=(RC[-2]-RC[-12])+(TIME(8,0,0)-RC[-12])"
[color=darkblue]If[/color] ActiveCell.Offset(0, -1) >= 1 [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) > Time(18, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=RC[-2]-TIME(8,0,0)"
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) <= Time(18, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=(TIME(18,0,0)-RC[-12])+(RC[-2]-TIME(8,0,0))"
[color=darkblue]GoTo[/color] Line4
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
Line3:
[color=darkblue]If[/color] ActiveCell.Offset(0, -14) = "Standard" [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) >= Time(10, 30, 0) [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) <= Time(16, 0, 0) [color=darkblue]Then[/color]
ActiveCell = Time(0, 15, 0)
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) > Time(16, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=(TIME(0,30,0))+((RC[-2])-TIME(16,0,0))"
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) < Time(10, 30, 0) [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -2) <= Time(10, 30, 0) [color=darkblue]Then[/color]
ActiveCell = Time(0, 15, 0)
[color=darkblue]If[/color] ActiveCell.Offset(0, -2) > Time(10, 30, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=(TIME(0,30,0))+((RC[-2])-TIME(16,0,0))"
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) > Time(16, 0, 0) [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -2) <= Time(10, 30, 0) [color=darkblue]Then[/color]
ActiveCell = Time(0, 15, 0)
[color=darkblue]If[/color] ActiveCell.Offset(0, -2) > Time(10, 30, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=(TIME(0,30,0))+((RC[-2])-TIME(10,30,0))"
[color=darkblue]If[/color] ActiveCell.Offset(0, -14) = "Urgent" [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -13) = "Sat/Sun" [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=RC[-2]-TIME(8,0,0)"
[color=darkblue]If[/color] ActiveCell.Offset(0, -1) = 0 [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) >= Time(8, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=RC[-2]-RC[-12]"
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) < Time(8, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=(RC[-2]-RC[-12])+(TIME(8,0,0)-RC[-12])"
[color=darkblue]If[/color] ActiveCell.Offset(0, -1) >= 1 [color=darkblue]Then[/color]
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) > Time(18, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=RC[-2]-TIME(8,0,0)"
[color=darkblue]If[/color] ActiveCell.Offset(0, -12) <= Time(18, 0, 0) [color=darkblue]Then[/color]
ActiveCell.FormulaR1C1 = "=(TIME(18,0,0)-RC[-12])+(RC[-2]-TIME(8,0,0))"
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
Line4:
ActiveCell.Offset(1, 0).Select
x = x + 1
[color=darkblue]Loop[/color] [color=darkblue]Until[/color] Cells(x, Column).Value = ""
Thanks