Here is a walkthrough of the situation:
- My excel has 2 tabs, one called AssetName Sheet and the other called AMP Sheet
- After clicking a vba button, the user is able to generate names in column B of the AssetName Sheet
I have another button that generates an AMP ID for the user. The easiest way for me to explain how this works is through an Index - Match function
=IFERROR(INDEX('AMP Sheet'!$L:$L,MATCH("*"&B2&"*", 'AMP Sheet'!$B:$B,0)), "Not Found")
Column B in the AssetName Sheet is named GeneratedAssetName and column L in the AMP Sheet is named ID.
So, in this example, My_Sandwich_6S_HeroRegular_Mobile exists in the AMP Sheet. Since this is a match, it will grab the associated ID from the AMP Sheet and copy it over to column E of the AssetName Sheet:
My logic (which does the exact same thing as the function I listed in step 3) is housed within a VBA macro button. The code is shown below:
Sub AMPTabid() Dim wsAN As Worksheet Set wsAN = Sheets("AssetName Sheet") Dim wsAMP As Worksheet Set wsAMP = Sheets("AMP Sheet") Dim LastRow As Long LastRow = wsAN.Cells(wsAN.Rows.Count, 2).End(xlUp).Row Dim i As Long For i = 2 To LastRow Dim rFind As range Set rFind = wsAMP.Columns(2).Find(what:=wsAN.Cells(i, 2), LookIn:=xlValues, LookAt:=xlPart, MatchCase:=True) If Not rFind Is Nothing Then wsAN.Cells(i, 5).Value = rFind.Offset(0, 10).Value End If Next i End Sub
Basically, I would like to use my existing code shown in step 4, but with column Names (rather than column numbers). The names I would like to use are Name and ID from the AMP Sheet.
The .Offset logic in my code is the tricky part, since it's going from column B to Column L in the AMP Sheet, so it count column L as 10, rather than 12.
Thanks!



