Karykatura
New Member
- Joined
- Jul 10, 2019
- Messages
- 1
Hi everyone,
First time posting so apologies if I commit any faux pas.
I have a classic problem with vlookup whereas I have multiple matching values but want to get a specific index.
I recently got into VBA and wrote a function which does the following:
Sub OverdoingIt()
Dim iRow As Long
On Error Resume Next
Set rng = Sheets("1").Range("A2:A600")
For Each Cell In rng
If Sheets("1").Cell.Value = Sheets("1").Cell.Value - 1 Then
If Sheets("1").Cells.Column(25).Value = "False" Then
Sheets("2").Cells(iRow, 8).Value = Application.WorksheetFunction.Index(Sheets("1").Range("AA:AA"), Application.WorksheetFunction.Match(1, Sheets("2").Cell.Range("A:A"), 0), 0)
End If
End If
Next Cell
End Sub
First time posting so apologies if I commit any faux pas.
I have a classic problem with vlookup whereas I have multiple matching values but want to get a specific index.
I recently got into VBA and wrote a function which does the following:
- In sheet 1 Looks if cell value is equal to the one above it
- If it is, looks if condition is met (X = False)
- Index/Match values from sheet 1 to sheet 2 and inserts the result into a specified cell in sheet
- Moves onto next cell in a row
Sub OverdoingIt()
Dim iRow As Long
On Error Resume Next
Set rng = Sheets("1").Range("A2:A600")
For Each Cell In rng
If Sheets("1").Cell.Value = Sheets("1").Cell.Value - 1 Then
If Sheets("1").Cells.Column(25).Value = "False" Then
Sheets("2").Cells(iRow, 8).Value = Application.WorksheetFunction.Index(Sheets("1").Range("AA:AA"), Application.WorksheetFunction.Match(1, Sheets("2").Cell.Range("A:A"), 0), 0)
End If
End If
Next Cell
End Sub