VBAMePlease
Board Regular
- Joined
- Jun 19, 2017
- Messages
- 59
VBA is assigned to a ActiveX Button on "Overview" sheet.
Script references all values in column D starting in row 2 on "DA_HRLY_LMP" sheet.
Script generates a list of unique values from ^ in a table on sheet "IDs".
From here I would use a simple VLOOKUP for the values generated in the table to find their associated ID... unless... the VLOOKUP function would have to be updated every time the script generates the table; at which point I'd like to have the script match the unique values generated with the associated ID in a separate field.
Here is my current code:
Any help is greatly appreciated.
Script references all values in column D starting in row 2 on "DA_HRLY_LMP" sheet.
Script generates a list of unique values from ^ in a table on sheet "IDs".
From here I would use a simple VLOOKUP for the values generated in the table to find their associated ID... unless... the VLOOKUP function would have to be updated every time the script generates the table; at which point I'd like to have the script match the unique values generated with the associated ID in a separate field.
Here is my current code:
Code:
Sub Fetch_IDs()Dim LastRowFrom As Long
Dim LastRowTo As Long
Dim i As Long, j As Long
Dim temp As Integer
Dim found As Boolean
Application.ScreenUpdating = False
Sheets(10).Select
LastRowFrom = Range("D" & Rows.Count).End(xlUp).Row
For i = 2 To LastRowFrom
temp = Range("D" & i).Value
LastRowTo = Range("D" & Rows.Count).End(xlUp).Row
j = 1
found = False
Do
If temp = Range("B" & j).Value Then
found = True
End If
j = j + 1
Loop Until found Or j = LastRowTo + 1
If Not found Then
Range("B" & j).Value = temp
End If
Next i
End Sub
Any help is greatly appreciated.
Last edited: