Depends on the code, can you please post it?
Sub trial()' Dim x As Long
' Dim y As Long
' Dim z As Long
' Dim first As Integer
' Dim second As Integer
' Dim third As Integer
' Dim season2 As String
' Dim season3 As String
Dim episodes As String
Dim episodes2 As String
Dim x As String
x = Sheets("Sheet1").Range("$E6").Value
season = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
episodes = 12
episodes2 = 14
' season2 = Sheets("Sheet1").Range("$E3").Value
' season3 = Sheets("Sheet1").Range("$E3").Value
'
' first = 10
' second = 13
' third = 13
'y = 1
'x = x + 1
If IsEmpty(Sheets("Sheet1").Range("$E6")) = True Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If IsEmpty(Sheets("Sheet1").Range("$E3")) = True Then
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
Else
Select Case x
Case 1
If x = 1 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 2
If x = 2 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 3
If x = 3 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 4
If x = 4 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 5
If x = 5 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 6
If x = 6 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 7
If x = 7 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 8
If x = 8 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 9
If x = 9 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 10
If x = 10 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 11
If x = 11 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 12
'If x = 12 Then
'Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
'If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = " "
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
'End If
'End If
Case 13
If x = 13 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
If x = 14 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If
End If
Case 14
If x = 14 Then
'Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
'If x = 14 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
'End If
End If
End Select
' If IsEmpty(Sheets("Sheet1").Range("$E6")) = False Then
' If Sheets("Sheet1").Range("$E6").Value = third Then
' Else
' Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
' End If
' If Sheets("Sheet1").Range("$E3").Value = "" Then
' Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
' End If
' End If
' If IsEmpty(Sheets("Sheet1").Range("$E3")) = False Then
' If Sheets("Sheet1").Range("$E6").Value = second Then
' If season3 = "3" Then
' Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
' Sheets("Sheet1").Range("$E6").Value = ""
' Else
' Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
' Sheets("Sheet1").Range("$E6").Value = ""
' End If
' End If
' End If
' If IsEmpty(Sheets("Sheet1").Range("$E3")) = False Then
' If season2 = "2" Then
' If season3 = "3" Then
' Else
' Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
' Sheets("Sheet1").Range("$E6").Value = ""
' End If
' End If
' End If
End If
End Sub
Case 1
[COLOR=#0000ff]If x = 1 Then[/COLOR]
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
[COLOR=#ff0000]If x = 12 Then
Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = ""
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
End If[/COLOR]
End If
Case 2
Case 12
[COLOR=#008000] 'If x = 12 Then
'Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1
'If x = 12 Then[/COLOR]
[COLOR=#ff0000]Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = " "[/COLOR]
Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1
[COLOR=#008000] 'End If
'End If[/COLOR]
Case 13
A select case is like multiple If statements, so with section of codeThe line in blue is redundant as it will only run that line if x=1, also the part in red is redundant as x can only be 1.Code:Case 1 [COLOR=#0000ff]If x = 1 Then[/COLOR] Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1 [COLOR=#ff0000]If x = 12 Then Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = "" Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1 End If[/COLOR] End If Case 2
Then if x=12 we get to hereWhere the line in red is saying E6=E6=" " which is a logical statement, so if E6=" " it will return TRUE otherwise it will return FALSE.Code:Case 12 [COLOR=#008000] 'If x = 12 Then 'Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value + 1 'If x = 12 Then[/COLOR] [COLOR=#ff0000]Sheets("Sheet1").Range("$E6").Value = Sheets("Sheet1").Range("$E6").Value = " "[/COLOR] Sheets("Sheet1").Range("$E3").Value = Sheets("Sheet1").Range("$E3").Value + 1 [COLOR=#008000] 'End If 'End If[/COLOR] Case 13
As that will only run if x=12 & x is the value of E6, then 12 does not equal " " so it will always return FALSE.
HTH
Sub trial()
With Sheets("Sheet1")
If .Range("E6") = 12 Then
.Range("E6").Value = ""
.Range("E3").Value = .Range("E3").Value + 1
Else
.Range("E6").Value = .Range("E6").Value + 1
If IsEmpty(.Range("$E3")) = True Then
.Range("$E3").Value = .Range("$E3").Value + 1
End If
End If
End With
End Sub
If I understand correctly, you can just doCode:Sub trial() With Sheets("Sheet1") If .Range("E6") = 12 Then .Range("E6").Value = "" .Range("E3").Value = .Range("E3").Value + 1 Else .Range("E6").Value = .Range("E6").Value + 1 If IsEmpty(.Range("$E3")) = True Then .Range("$E3").Value = .Range("$E3").Value + 1 End If End If End With End Sub