Option Explicit
Sub Reset2()
Dim lastr As Long
Dim lastc As Integer
Dim myRange As Range
Dim cell As Range
Dim Rcolumn As Integer
Dim Acolumn As Integer
Dim RAddress As String
Dim Aoffset As Integer
Dim Aaddress As String
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("Sheet1").Activate
lastr = Cells(65536, 1).End(xlUp).Row
lastc = Cells(1, 255).End(xlToLeft).Column
'=========================================
'Finds the two columns, Award and Rank
Cells.Find(What:="Award", After:=Cells(1, 1), SearchDirection:=xlNext).Activate
Acolumn = ActiveCell.Column
Aaddress = ActiveCell.Offset(1, 0).Address
Cells.Find(What:="Rank", After:=Cells(1, 1), SearchDirection:=xlNext).Activate
Rcolumn = ActiveCell.Column
RAddress = ActiveCell.Offset(1, 0).Address
'Gets the offset from rank to award
Aoffset = Acolumn - Rcolumn
Set myRange = Nothing
'Sets myRange to a new range -> the cells in the rank column
Set myRange = ActiveSheet.Range(RAddress, ActiveSheet.Cells(lastr, Rcolumn)) 'Range AA2:AA225 in this sheet
'*******It is this for loop that takes so long
For Each cell In myRange
Select Case cell.Value
Case Is = "1"
cell.Offset(0, Aoffset).Value = "Yes"
Case Else
cell.Offset(0, Aoffset).Value = "No"
End Select
Next cell
'**************************
Set myRange = Nothing
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
|