I'm trying to figure out how to use VBA to reference a column by number instead of by letter.
The end goal of this portion of code is to insert a column for A, then in Column A flag each record with a "1" if it meets a series of conditions. The conditions are found in the "ConditionColumn" which will change location (which is why I'm trying to keep this variable instead of hard coding".
The line of code that I can't get to work is as follows:
Below is the full for this task.
If anyone could help me see what I'm doing wrong and help find a better way to accomplish this I'd be quite appreciative. I think it's something simple I'm just overlooking. Thanks in advance!
The end goal of this portion of code is to insert a column for A, then in Column A flag each record with a "1" if it meets a series of conditions. The conditions are found in the "ConditionColumn" which will change location (which is why I'm trying to keep this variable instead of hard coding".
The line of code that I can't get to work is as follows:
HTML:
If Range(Columns(ConditionColumn), ReviewRowNumber) = 7 Then
Below is the full for this task.
HTML:
Dim ReviewRowNumber As Long
Dim LastRowNumber As Long
Dim ConditionColumn As Double
Sheets("MSS Data").Select
LastRowNumber = Range("A1048576").End(xlUp).Row
Columns(1).Insert
ConditionColumn = WorksheetFunction.Match("Conditions", Sheets("MSS Data").Range("1:1"), 0)
ReviewRowNumber = 2
While ReviewRowNumber <= LastRowNumber
If Range(Columns(ConditionColumn), ReviewRowNumber) = 7 Then
Range(A & ReviewRowNumber).Value = 1
End If
ReviewRowNumber = ReviewRowNumber + 1
Wend
If anyone could help me see what I'm doing wrong and help find a better way to accomplish this I'd be quite appreciative. I think it's something simple I'm just overlooking. Thanks in advance!