dimanche 22 octobre 2017

Is there a more efficient method for For-Next including If-Then statement?

I am in a process of improving the efficiency of two macros. I have managed to improve all of their methods besides the one described on the title. It is fully functional, but I am sure there is a better way to right the part of the code I am providing below:

For Each cell2 In Range("L2:L" & lastrow2)
  If Not cell2.Offset(0, -1).Value = 0 Then
    If cell2.Offset(0, -5).Value = "SOCHACZEW" Then
    cell2.Value = 31.2
    ElseIf cell2.Offset(0, -5).Value = "SEKERPINAR" Then
    cell2.Value = 33
    ElseIf cell2.Offset(0, -5).Value = "ATHENS" Then
    cell2.Value = 28
    ElseIf cell2.Offset(0, -5).Value = "MECHELEN" Then
    cell2.Value = 33
    ElseIf cell2.Offset(0, -5).Value = "TIMISOARA" Then
    cell2.Value = 34
    ElseIf cell2.Offset(0, -5).Value = "STRANCICE" Then
    cell2.Value = 33
    ElseIf cell2.Offset(0, -5).Value = "KLIPPAN" Then
    cell2.Value = 33
    ElseIf cell2.Offset(0, -5).Value = "MATARO" Then
    cell2.Value = 33
    ElseIf cell2.Offset(0, -5).Value = "KIEV" Then
    cell2.Value = 32
    ElseIf cell2.Offset(0, -5).Value = "ROSTOV" Then
    cell2.Value = 32.6
    ElseIf cell2.Offset(0, -5).Value = "ITELLA" Then
    cell2.Value = 32
    End If
  End If
Next cell2

Aucun commentaire:

Enregistrer un commentaire