Value Extract - VBA

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:

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:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top