Nonsense, c is a range and he is picking up the range object and setting its
value property, that is legitimate.
Damien,
Not sure how much difference, but this might be somewhat faster. On
specifics, should you be setting it back to Automatic calculation on a value
of E, it will stay auto thereafter. I would have thought you do that after
all cells are processed.
Sub GetWeek1Data()
Dim c As Range
Dim LookupRange As Range
Dim LookupValue
Dim LookupRevTable As Range
Dim ImportInd
Dim BR1Rev As Double
Dim Br2Rev As Double
Dim Br3Rev As Double
Dim Br4Rev As Double
Dim Br5Rev As Double
Application.Calculation = xlCalculationManual
On Error Resume Next
With ActiveSheet
Set LookupRevTable = .Range("REVTABLE")
For Each c In Range("E4:E500")
ImportInd = .Cells(c.Row, 2).Value
Select Case ImportInd
Case Is = "A"
LookupValue = .Cells(c.Row, 1).Value
LookupRange = .Range("Week1")
c.Value = Application.VLookup(LookupValue,
LookupRange, 4, False)
Case Is = "R"
LookupValue = CStr(.Range("Branch1").Value & _
Left(.Cells(c.Row, 1).Value, 6) & _
.Cells(2, c.Column).Value)
BR1Rev = Application.VLookup(LookupValue,
LookupRevTable, 5, False) * -1
If Range("Branch2").Value = "" Then
GoTo cont
Else
LookupValue = CStr(.Range("Branch2").Value & _
Left(.Cells(c.Row, 1).Value, 6) & _
.Cells(2, c.Column).Value)
Br2Rev = Application.VLookup(LookupValue,
LookupRevTable, 5, False) * -1
End If
If Range("Branch3").Value = "" Then
GoTo cont
Else
LookupValue = CStr(.Range("Branch3").Value & _
Left(.Cells(c.Row, 1).Value, 6) & _
.Cells(2, c.Column).Value)
Br3Rev = Application.VLookup(LookupValue,
LookupRevTable, 5, False) * -1
End If
If Range("Branch4").Value = "" Then
GoTo cont
Else
LookupValue = CStr(.Range("Branch4").Value & _
Left(.Cells(c.Row, 1).Value, 6) & _
.Cells(2, c.Column).Value)
Br4Rev = Application.VLookup(LookupValue,
LookupRevTable, 5, False) * -1
End If
If Range("Branch5").Value = "" Then
GoTo cont
Else
LookupValue = CStr(.Range("Branch5").Value & _
Left(.Cells(c.Row, 1).Value, 6) & _
.Cells(2, c.Column).Value)
Br5Rev = Application.VLookup(LookupValue,
LookupRevTable, 5, False) * -1
End If
cont:
c.Value = BR1Rev + Br2Rev + Br3Rev + Br4Rev + Br5Rev
BR1Rev = 0: Br2Rev = 0: Br3Rev = 0: Br4Rev = 0: Br5Rev
= 0
Case Is = "P"
c.Value = .Cells(c.Row, 3).Value
Case Is = "E"
' "E" is used at the end of the list to stop the
for..next
Application.Calculate
Application.Calculation = xlCalculationAutomatic
Exit Sub
Case Else
End Select
Next c
End With
End Sub
--
---
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)