I'm trying to highlight an adjacent cell when a certain value is found in a cell given a range to look through. I used to do this with a simple loop, but now the data has gotten so large that looping takes forever. I'm trying an autofilter workaround to speed things up.
In short, what I think I need is to select a range using autofilter (always one column wide), and then set a new range, shifting one column to the right, so that I can highlight that column.
This is what I've got, but Excel doesn't like my "Set newrange...Offset"
In short, what I think I need is to select a range using autofilter (always one column wide), and then set a new range, shifting one column to the right, so that I can highlight that column.
This is what I've got, but Excel doesn't like my "Set newrange...Offset"
Code:
Sub highlight()
Dim limitrows As Integer
Dim startrow As Integer
Dim whichcolumn As String
Dim highlightcolumn As String
Dim subject As String
Dim myrange As Range
Dim newrange As Range
whichcolumn = InputBox("Which column should I look in?", "Subject Column")
highlightcolumn = InputBox("Which column should I highlight when found?", "Highlight Column")
subject = InputBox("What should I look for?", "Subject")
startrow = Val(InputBox("Which row should I begin with?", "Start Row"))
limitrows = Val(InputBox("How many rows should I look through?", "Row Limit"))
Set myrange = Range(whichcolumn & startrow, whichcolumn & limitrows)
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
myrange.AutoFilter Range(whichcolumn & 1, whichcolumn & 1).Column, subject
Set newrange = myrange.Parent.AutoFilter.Range.Cells(1).Offset(0, 1)
newrange.Cells.Interior.Color = RGB(255, 255, 0)
myrange.Parent.AutoFilterMode = False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub