Can't get code to run automatically

joacro

Board Regular
Joined
Jun 24, 2010
Messages
158
Hi there,

Wonder if someone can help.

I cant get the code below to run automatically everytime "I" is changed

Sub looping_code()
Dim LR As Long
Dim i As Long

LR = Range("G" & Rows.Count).End(xlUp).Row

For i = 1 To LR
If Range("I" & i) = 90000 Then
If Range("G" & i) >= 90000 Then
Range("K" & i) = "Gold"
ElseIf Range("G" & i) >= 70000 Then
Range("K" & i) = "Silver"
ElseIf Range("G" & i) >= 45000 Then
Range("K" & i) = "Bronze"
Else
Range("K" & i) = "Blue"
End If
ElseIf Range("I" & i) = 120000 Then
If Range("G" & i) >= 120000 Then
Range("K" & i) = "Gold"
ElseIf Range("G" & i) >= 90000 Then
Range("K" & i) = "Silver"
ElseIf Range("G" & i) >= 70000 Then
Range("K" & i) = "Bronze"
Else
Range("K" & i) = "Blue"
End If
End If
Next i
End Sub

Regards
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
The code should be in the 'sheet' and should be the "Worksheet_Change" event.
If you want it to do something only when a cell in that column changes, you need to start with the following:
Code:
If Target.Column <> 9 Then
     Exit Sub
End If
Of course, if you have many rows you may find the processing (and re-calculations) will slow you down.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top