G
Guest
I'll post my macro below, but the question is, why am I getting an error?
Says that theres an Else without an IF, but I have 2 elses and 2 ifs. One
for each one?
Sub Button2_Click()
Dim col As Variant
Dim rang As Variant
Dim col2 As Variant
Dim end1 As Variant
end1 = 1
Range("C3").Select
ActiveCell.FormulaR1C1 = "1"
Range("D3").Select
Do Until end1 = 8000
rang = Range("E3").Value
col = Range(rang).Value
Range(rang).Select
If col < 100 Then
With Selection.Interior
.ColorIndex = col
.Pattern = xlSolid
End With
Selection.Font.ColorIndex = col
Else
If col = 104 Then
With Selection.Interior
.ColorIndex = 3
.Pattern = xlGray25
.PatternColorIndex = xlAutomatic
Selection.Font.ColorIndex = 3
Else
col2 = col - 100
With Selection.Interior
.ColorIndex = col2
.Pattern = xlGray8
.PatternColorIndex = xlAutomatic
Selection.Font.ColorIndex = col2
End If
End If
Range("D3").Select
Selection.Copy
Range("C3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
end1 = Range("C3").Value
Loop
End Sub
Says that theres an Else without an IF, but I have 2 elses and 2 ifs. One
for each one?
Sub Button2_Click()
Dim col As Variant
Dim rang As Variant
Dim col2 As Variant
Dim end1 As Variant
end1 = 1
Range("C3").Select
ActiveCell.FormulaR1C1 = "1"
Range("D3").Select
Do Until end1 = 8000
rang = Range("E3").Value
col = Range(rang).Value
Range(rang).Select
If col < 100 Then
With Selection.Interior
.ColorIndex = col
.Pattern = xlSolid
End With
Selection.Font.ColorIndex = col
Else
If col = 104 Then
With Selection.Interior
.ColorIndex = 3
.Pattern = xlGray25
.PatternColorIndex = xlAutomatic
Selection.Font.ColorIndex = 3
Else
col2 = col - 100
With Selection.Interior
.ColorIndex = col2
.Pattern = xlGray8
.PatternColorIndex = xlAutomatic
Selection.Font.ColorIndex = col2
End If
End If
Range("D3").Select
Selection.Copy
Range("C3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
end1 = Range("C3").Value
Loop
End Sub