First part of IF statement is being ignored - excel

I have the following IF statement in VBA, but the "delete" part of the statement, or the bit before the ElseIf, is completely ignored:
For i = 3 To (customerNum + 3)
If Sheets("Reports").Range("L" & i).Value = "A" Then
Sheets("Reports").Range("G" & i & ":M" & i).Select
Selection.Delete Shift:=xlUp
ElseIf Sheets("Reports").Range("L" & i).Value <> "A" Then
Sheets("Reports").Range("J" & i).Value = form1_1 & i & form1_2
Sheets("Reports").Range("J" & i).NumberFormat = "d-mmm-yy"
Sheets("Reports").Range("M" & i).Value = form2_1 & i & form2_2 & i
Sheets("Reports").Range("M" & i).NumberFormat = "_-[$£-809]* #,##0.00_-;-[$£-809]* #,##0.00_-;_-[$£-809]* ""-""??_-;_-#_-"
End If
Next i
The rest runs smoothly. No crashes or bugs.
Any ideas?

This is not (!) supposed to be an additional answer. Yet, I would like to add this "answer" because (occasionally) I encountered the problem of various different "A"s or "C"s (etc.) in one Excel sheet. Working in large corporations I had colleagues working with multiple different character sets at a time (their native character set and the English one). Note that the cyrillic "A" looks like the latin "A". Yet, even with Option Compare Text the two are different. The following code will reveal the unicode of a character and might be a better way of checking if an "A" has been entered into a particular cell:
Public Sub CheckUnicode()
Dim lngRowNumber As Long
Debug.Print AscW("A")
With Sheets("Reports")
For lngRowNumber = 1 To 100000
If Trim(.Range("L" & lngRowNumber).Value2) = vbNullString Then Exit For
Debug.Print AscW(Left(.Range("L" & lngRowNumber).Value2, 1))
Next lngRowNumber
' The following will append a cyrillic a to the bottom of the sheet in Column "A"
.Range("A" & lngRowNumber + 1).Value2 = ChrW(1072)
End With
End Sub
I am merely addition this "solution" for others who might encounter a similar problem. As mentioned before there are several characters which look alike but are not. Also note, that this is only the cyrillic alphabet. There might be other character sets out there which seem to look alike.

Maybe you need to start from the bottom then go up.
Sub Button1_Click()
Dim sh As Worksheet
Dim Rws As Long, rng As Range, nwrw As Long
Set sh = Sheets("Reports")
With sh
Rws = .Cells(.Rows.Count, "L").End(xlUp).Row
For i = Rws To 3 Step -1
If .Cells(i, "L") = "A" Then .Range(.Cells(i, "G"), .Cells(i, "M")).Delete Shift:=xlUp
If .Cells(i, "L") <> "A" Then
.Cells(i, "J") = "something" & i & "something else"
.Cells(i, "M") = "something" & i & "something else"
End If
Next i
End With
End Sub

Related

Comparing values from 2 sheets

compare values from 1 column in a sheet to another column in a different sheet. If the value is the same, update the cell string to “Special”
I have a code that checks for type of each case I have, so when macros identifies that type it is the string in the cell changes for a specific name.
However, I need to create a new type named Special, when the value on alert_list.Range("E") is NOT "Multi" and the value on alert_list.Range("C") is "Corp". Then the value on column F should be compared to the value on column B in a sheet named child_list to see if it is the same value and if it is the same then a string Special need appear in the cell on the place of "Corp" on alert_list.Range("C").
I create a list on column B in a sheet named child_list and I need to compare this values with the information in another sheet named alert_list column F.
everything above is working I am trying to create another step to be able to have a new type named Special.
If ABC.Range("E" & i).Value <> "Multi" And ABC.Range("C" & i).Value = "Corp" Then
For k = 2 To Ch_lRow
If ABC.Range("F" & i).Value <> TEXT.Range("B" & k).Value Then
'do nothing
Else
If alert_list.Range("F" & i).Value = TEXT.Range("B" & k).Value Then
ABC.Range("C" & i).Value = "GOOD"
End If
Next
End If
Exit Sub
But for some reason unknown for me it is not working, I am not getting error However, or it jumps directly to exit sub or just nothing happen after run the code.
It's a bit tricky to explain in comments so here is an answer to explain.
You are executing an Exit Sub statement after your first If...Then...Else block.
If we use some proper indentation, it's much easier to identify this:
Dim Ch_lRow As Long
Ch_lRow = child_list.Cells(Rows.Count, 2).End(xlUp).Row
If alert_list.Range("E" & i).Value <> "Multi" And alert_list.Range("C" & i).Value = "Corp" Then
For k = 2 To Ch_lRow
If alert_list.Range("F" & i).Value <> child_list.Range("B" & k).Value Then
'do nothing
Else
If alert_list.Range("F" & i).Value = child_list.Range("B" & k).Value Then
alert_list.Range("C" & i).Value = "Special"
End If
Next
End If
Exit Sub
This additional block you want to add in is obviously within your first loop:
For i = 2 To lRow
...
Dim Ch_lRow As Long
Ch_lRow = child_list.Cells(Rows.Count, 2).End(xlUp).Row
If alert_list.Range("E" & i).Value <> "Multi" And alert_list.Range("C" & i).Value = "Corp" Then
For k = 2 To Ch_lRow
If alert_list.Range("F" & i).Value <> child_list.Range("B" & k).Value Then
'do nothing
Else
If alert_list.Range("F" & i).Value = child_list.Range("B" & k).Value Then
alert_list.Range("C" & i).Value = "Special"
End If
Next
End If
Exit Sub
Next i
So this means you have an Exit Sub within your loop, so, within the first iteration the code will fire Exit Sub and your code will do nothing as you put it.
Remove the exit sub from this location and put it outside your For i = 2 to lRow loop as required.

Search columns for keywords from a list and return any matches to a different column

Hello and thanks in advance for any assistance. I have a work sheet with two tabs named DATA PULL and LIST. The LIST tab contains a list of keywords (250 words) in column A. I need to search for those key words in columns P and Q on the DATA PULL tab and return any matches to column I(the data is in a table). Columns P and Q contain multiple words or sentences.
The code below does what I need but the list of key words is on the same sheet. This code also deletes letters from my table headers for some reason.
Sub GetWords()
Dim wrdLRow As Integer
Dim wrdLp As Integer
Dim CommentLrow As Integer
Dim CommentLp As Integer
Dim fndWord As Integer
Dim Sht As Worksheet
On Error Resume Next 'Suppress Errors... for when we don't find a match
'Define worksheet that has data on it....
Set Sht = Sheets("DATA PULL")
'Get last row for words based on column A
wrdLRow = Sht.Cells(Rows.Count, "A").End(xlUp).Row
'Get last row for comments based on column C
CommentLrow = Sht.Cells(Rows.Count, "P").End(xlUp).Row
'Loop through lists and find matches....
For CommentLp = 2 To CommentLrow
For wrdLp = 2 To wrdLRow
'Look for word...
fndWord = Application.WorksheetFunction.Search(Sht.Cells(wrdLp, "A"), Sht.Cells(CommentLp, "P"))
'If we found the word....then
If fndWord > 0 Then
Sht.Cells(CommentLp, "I") = Sht.Cells(CommentLp, "I") & "; " & Sht.Cells(wrdLp, "A")
fndWord = 0 'Reset Variable for next loop
End If
Next wrdLp
Sht.Cells(CommentLp, "I") = Mid(Sht.Cells(CommentLp, "I"), 3, Len(Sht.Cells(CommentLp, "I")) - 2)
Next CommentLp
End Sub
Any help is greatly appreciated.
LIST
DATAPULL
Some tips for your code:
Using a
On error Resume Next
like you are using is a bad practice and can result in trouble. You might have other errors that won't show up because of that, and this will prevent you from debugging them and finding the problem. I would recommend using it only before the problematic line, and after that using
On Error goto 0
to resume showing and finding other possible errors.
A way of totally avoiding having to use "On Error Resume Next" is using the "Like" Operator. If you use
If Sht.Cells(CommentLp, "P") Like "*" & Sht.Cells(wrdLp, "A") & "*" Then
Sht.Cells(CommentLp, "I") = Sht.Cells(CommentLp, "I") & "; " & Sht.Cells(wrdLp, "A")
End If
You can do the same thing without worrying about errors. Basically, "Like" does a search to see if a text looks like the other. The two "*" means any kind and number of characters, so all together means that Sht.Cells(CommentLp, "P") must be like: any kind and number of characters, followed by the value of Sht.Cells(wrdLp, "A"), followed by any kind or number of characters. Just like "Search" =) !
Doing this change also forced me to adapt the way you are dealing with the starting "; " in your code, but also for a better way:
Dim wrdLRow As Integer
Dim wrdLp As Integer
Dim CommentLrow As Integer
Dim CommentLp As Integer
Dim fndWord As Integer
Dim DataSht As Worksheet
Dim ListSht as Worksheet
'Define the worksheets
Set DataSht = Sheets("DATA PULL")
Set ListSht = Sheets("LIST")
'Get last row for words based on column A
wrdLRow = ListSht.Cells(Rows.Count, "A").End(xlUp).Row
'Get last row for comments based on column C
CommentLrow = DataSht.Cells(Rows.Count, "P").End(xlUp).Row
For CommentLp = 2 To CommentLrow
For wrdLp = 2 To wrdLRow
If LCASE(DataSht.Cells(CommentLp, "P")) Like "*" & LCASE(ListSht.Cells(wrdLp, "A")) & "*" Then
If DataSht.Cells(CommentLp, "I") <> "" Then
DataSht.Cells(CommentLp, "I") = DataSht.Cells(CommentLp, "I") & "; " & ListSht.Cells(wrdLp, "A")
Else
DataSht.Cells(CommentLp, "I") = ListSht.Cells(wrdLp, "A")
End If
ElseIf LCASE(Sht.Cells(CommentLp, "Q")) Like "*" & LCASE(Sht.Cells(wrdLp, "A")) & "*" Then
If NewSht.Cells(writeRow, "A") <> "" Then
NewSht.Cells(writeRow, "A") = NewSht.Cells(writeRow, "A") & "; " & Sht.Cells(wrdLp, "A")
Else
NewSht.Cells(writeRow, "A") = Sht.Cells(wrdLp, "A")
End If
End If
Next wrdLp
Next CommentLp
This code runs for me without a problem, but so did yours. I am assuming you didn't share your whole code, also because you mentioned two columns and only wrote the code for one. I think the problem might be in the part you didn't share, and perhaps this modification I wrote, without the "On Error Resume Next", you help you find it!
I just hoped I didn't get confused with the variables and list, but I think now you can have a good idea of what I am doing. Hope it helps.
I think you could try this:
EDITED VERSION:
Option Explicit
Sub test()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim LRA As Long, i As Long, LRP As Long, LRQ As Long, LRI As Long
Dim SearchingValue As String
Dim rng As Range, cell As Range
With ThisWorkbook
Set ws1 = .Worksheets("DATA PULL")
Set ws2 = .Worksheets("LIST")
With ws1
LRP = .Cells(.Rows.Count, "P").End(xlUp).Row
LRQ = .Cells(.Rows.Count, "Q").End(xlUp).Row
Set rng = .Range("P1:P" & LRP, "Q1:Q" & LRQ)
End With
With ws2
LRA = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LRA
SearchingValue = .Range("A" & i).Value
For Each cell In rng
If InStr(1, cell.Value, SearchingValue) > 0 Then
With ws1
LRI = .Cells(.Rows.Count, "I").End(xlUp).Row
.Range("I" & LRI + 1).Value = "Value " & """" & .Range("A" & i).Value & """" & " appears in sheet DATA PULL, " & "column " & cell.Column & ", row " & cell.Row & "."
Exit For
End With
End If
Next cell
Next i
End With
End With
End Sub

How can I test for Three Conditions, and then delete an entire row if all conditions are TRUE?

I have a sheet that I want to check the language in Column R for <> ‘Cash’; if ‘Cash’ do skip to the next row. If Column R <> ‘Cash’, check Column A for duplicate ID (there may or may not be duplicates). If duplicates are found, I want to check Column K for positive/negative values, like 100000 & -100000, then delete the entire row where the negative value appears in Column K. How can I do that?
Following the roles described above, row 6 would be deleted in the image below.
I could use VBA in Excel, or SQL/VBA in Access.
This seems to work pretty well.
Sub TryMe()
Dim i As Long
Dim j As Long
Dim ws As Worksheet
Set ws = Sheet1
For i = 2 To 13
For j = 2 To 13
If ws.Range("A" & i).Value = ws.Range("A" & j).Value Then
If ws.Range("A" & i).Offset(0, 10).Value = -(ws.Range("A" & j).Offset(0, 10).Value) Then
If ws.Range("A" & i).Offset(0, 17).Value <> "Cash" Then
Rows(i).EntireRow.Delete
End If
End If
Exit For
End If
Next j
Next i
End Sub

Prevent inclusion of sheet names when adding a name for range of cells with vba

I'm working with some data on Excel 2011 for Mac (version 14.3.1) that I need to graph and add more data later on. To do that, I'm using names for ranges as it is explained here. Basically, create Name ranges with the formula =OFFSET($A$2,0,0,COUNTA($A:$A)-1) (in spanish: =DESREF($A$2,0,0,CONTARA($A:$A)-1)).
I have many columns, so I wrote this vba to do it for me:
Sub Botón6_AlHacerClic()
For i = 1 To Columns.Count
Names.Add Name:=ActiveSheet.Name & Range(Cells(1, i).Address).Value, RefersTo:="=DESREF(" & Cells(2, i).Address & ",0,0,CONTARA(" & Replace(Cells(1, i).Address, "$1", "") & ":" & Replace(Cells(1, i).Address, "$1", "") & ")-1)"
Next i
End Sub
Where:
Cells(2, i).Address is the cell id for the second row (Eg: $A$2)
Replace(Cells(1, i).Address, "$1", "") is the row letter (Eg: $A)
The problem I'm having is that when entering the names manually, it replaces the formula =DESREF($A$2,0,0,CONTARA($A:$A)-1) with =DESREF(Sheet1!$A$2,0,0,CONTARA(Sheet1!$A:$A)-1) which is fine and works great. But when I do it by the vba, it replaces it with =Sheet1!DESREF(Sheet1!$A$2,0,0,CONTARA(Sheet1!$A:$A)-1) that doesn't work.
I tried with the different options of the Add manual and even tried to run this code after the names are created to eliminate the Sheet1! at the beginning but at the end they keep the Sheet1!:
Sub Botón7_AlHacerClic()
Set nms = ActiveWorkbook.Names
For i = 1 To nms.Count
nms(i).RefersTo = Replace(nms(i).RefersTo, ActiveSheet.Name & "!DESREF", "DESREF")
Next i
End Sub
Another thing I tried was to replace the Sheet1!DESREF for something that is not a function:
Sub Botón7_AlHacerClic()
Set nms = ActiveWorkbook.Names
For i = 1 To nms.Count
nms(i).RefersTo = Replace(nms(i).RefersTo, ActiveSheet.Name & "!DESREF", "DESREFF")
Next i
End Sub
And in this case it gives me: =DESREFF($A$2,0,0,CONTARA($A:$A)-1) But I haven't find a way to do it with the DESREFwithout adding the Sheet1!
How can I prevent the Sheet1! from appearing at the beginning?
Thank you
I've tried with different versions of Excel and it seems to be a bug in Excel 2011 for Mac (version 14.3.1).
I tried it in the following versions and it didn't add the Sheet1! at the beginning:
Excel for Mac 14.3.9
Excel for Windows 16.0.6001.1054
The problem now with both of those versions is the following:
I have a column with the following cells:
C1-> data
C2-> 400
C3-> 100
C4-> 100
And after C5 empty. I run the script to create the names:
Sub Botón6_AlHacerClic()
For i = 1 To Columns.Count
Names.Add Name:=ActiveSheet.Name & Range(Cells(1, i).Address).Value, RefersTo:="=DESREF(" & Cells(2, i).Address & ",0,0,CONTARA(" & Replace(Cells(1, i).Address, "$1", "") & ":" & Replace(Cells(1, i).Address, "$1", "") & ")-1)"
Next i
End Sub
And it created me the name Sheet1data with the reference: =DESREF(Sheet1!$C$2;0;0;CONTARA(Sheet1!$C:$C)-1) which is correct. But if I go to any cell and insert the formula =SUM(Sheet1data) it resolves with a formula error #Name?, even though explaining the formula seems to point to the right cells.
More strange, if after creating it I go to edit the name and just hit Enter, the formula works automatically and presents 600. If I go again to the name editor it shows =DESREF(Sheet1!$C$2;0;0;CONTARA(Sheet1!$C:$C)-1), which is the same as before.
Finally I found this web with examples where there was one explaining something similar to what I wanted to do:
Sub DynamicNames()
Dim LastCol As Long, _
LabelRow As Long, _
Col As Long
Dim sName As String
Dim c As Range
Dim Sht As String
'assign row and column parameters
'**adjust for the row containing your headings
LabelRow = 1
LastCol = Range("IV1").End(xlToLeft).Column
'grab sheet name
Sht = "'" & ActiveSheet.Name & "'"
For Each c In Range(Cells(LabelRow, 1), Cells(LabelRow, LastCol))
Col = c.Column
sName = c.Value
If Len(sName) > 1 Then
'replace spaces with underscores
sName = Replace(sName, " ", "_", 1)
'create the name
ActiveWorkbook.Names.Add Name:=sName, RefersToR1C1:= _
"=OFFSET(" & Sht & "!R2C" & Col & ",0,0,COUNTA(" & Sht & "!C" & Col & ")-1,1)"
End If
Next c
End Sub
The main difference is that they where using RefersToR1C1 instead of RefersTo, so I changed it but it still wasn't working. Finally I changed the formulas to english even though I had to write them in spanish by hand and that did the final trick: Names.Add Name:=ActiveSheet.Name & Range(Cells(1, i).Address).Value, RefersToR1C1:="=OFFSET(" & ActiveSheet.Name & "!R2C" & Cells(2, i).Column & ",0,0,COUNTA(" & ActiveSheet.Name & "!C" & Cells(2, i).Column & ")-1)"
So, the problems where:
The Excel 2011 for Mac (version 14.3.1) seems to have a bug.
Using RefersToR1C1 instead of RefersTo makes it easier to work with vba formulas and maybe it helped.
Even though in all my Excel I use spanish formulas, the ones in vba have to be in english. (I tried the parameter _ RefersToR1C1Local_ but it gave me an error).
Finally, the code that worked:
Sub Botón6_AlHacerClic()
For i = 1 To Columns.Count
Names.Add Name:=ActiveSheet.Name & Range(Cells(1, i).Address).Value, RefersToR1C1:="=OFFSET(" & ActiveSheet.Name & "!R2C" & Cells(2, i).Column & ",0,0,COUNTA(" & ActiveSheet.Name & "!C" & Cells(2, i).Column & ")-1)"
Next i
End Sub
I hope it helps someone out there :)

How to optimize Macro Code That Looks into 2 Worksheets

Problem:
I have 1 Excel Sheet with 2 tabs
Tab 1 = Shipment Package
Tab 2 = Mass Update Steps
I want to go through all the values in column B of Tab 2 one by one.
As I go through each row in Tab 2, I will select and copy the values in column C and D of Tab 2.
After selecting and copying, I want to find Tab 2-column B's corresponding values in Tab 1 column G.
If a match is found, I will select column E of Tab 1 (in row where the match was found), and paste there the values copied from Tab 2.
So far this is the code I have which works. However the values from being searched are hard coded. With the values growing in number in Tab 2, the code is hard to maintain. I would like to optimize it. I have googled several possible solutions. But I keep on getting these run-time errors when declaring or setting the range for the 2 sheets. Here is my code.
Private Sub btn_Updt_Steps_Click()
Dim lastRow As Long
With Sheets("Shipment Package")
.Activate
lastRow = .Range("G65000").End(xlUp).Row
For i = 1 To lastRow
If (InStr(1, .Range("G" & i).Value, "Code 001", vbTextCompare) > 0) Then
Sheets("Mass Update Steps").Activate
ActiveSheet.Range("C4:D4").Select
Selection.Copy
Sheets("Shipment Package").Activate
.Range("E" & i).Select
ActiveSheet.Paste
ElseIf (InStr(1, .Range("G" & i).Value, "Code 002", vbTextCompare) > 0) Then
Sheets("Mass Update Steps").Activate
ActiveSheet.Range("C5:D5").Select
Selection.Copy
Sheets("Shipment Package").Activate
.Range("E" & i).Select
ActiveSheet.Paste
ElseIf (InStr(1, .Range("G" & i).Value, "Code 003", vbTextCompare) > 0) Then
Sheets("Mass Update Steps").Activate
ActiveSheet.Range("C6:D6").Select
Selection.Copy
Sheets("Shipment Package").Activate
.Range("E" & i).Select
ActiveSheet.Paste
End If
Next
End With
NotFoundErr:
Debug.Print "value not found"
End Sub
Solution:
Private Sub btn_Updt_Steps_Click()
Dim i As Long
Dim j As Long
Dim Tab2ColC As String
Dim Tab2ColD As String
Dim Tab1ColE As String
Dim Tab1ColF As String
Tab1 = "Shipment Package"
Tab2 = "Mass Update Steps"
With Worksheets(Tab1)
LastRowTab1 = .Cells(.Rows.Count, "G").End(xlUp).Row 'LastRowInColumn(2, Tab1)
End With
With Worksheets(Tab2)
LastRowTab2 = .Cells(.Rows.Count, "B").End(xlUp).Row 'LastRowInColumn(2, Tab2)
End With
For i = 4 To LastRowTab2
Tab2ColumnB = Trim(Sheets(Tab2).Range("B" & i).Value)
Sheets(Tab2).Activate
If Tab2ColumnB <> "" Then
Tab2ColC = "C" & i
Tab2ColD = "D" & i
ActiveSheet.Range(Tab2ColC, Tab2ColD).Copy
For j = 16 To LastRowTab1
Tab1ColumnG = Trim(Sheets(Tab1).Range("G" & j).Value)
If Tab1ColumnG = Tab2ColumnB Then
Sheets(Tab1).Activate
Tab1ColE = "E" & j
Tab1ColF = "F" & j
Sheets(Tab1).Range(Tab1ColE, Tab1ColF).Select
ActiveSheet.Paste
End If
Next
End If
Next
End Sub
For optimization, you can avoid select statements, activate statements etc. Check the code below.
For i = 1 To lastRow
Application.ScreenUpdating = False
If YourCondn1 Then
Sheets("Mass Update Steps").Range("C4:D4").Copy
Sheets("Shipment Package").Range("E" & i).PasteSpecial xlPasteAll
ElseIf YourCondn2 Then
Sheets("Mass Update Steps").Range("C5:D5").Copy
Sheets("Shipment Package").Range("E" & i).PasteSpecial xlPasteAll
ElseIf YourCondn3 Then
Sheets("Mass Update Steps").Range("C6:D6").Copy
Sheets("Shipment Package").Range("E" & i).PasteSpecial xlPasteAll
End If
Application.ScreenUpdating = True
Next
Adding the code that you require. Hope this will work. I haven't tested it. Please check.
Private Sub btn_Updt_Steps_Click()
'Finding LastRow in Tab 2
Tab1 = "Shipment Package"
Tab2 = "Mass Update Steps"
With Worksheets(Tab2)
LastRowTab2 = .Cells(.Rows.Count, 2).End(xlUp).Row 'LastRowInColumn(2, Tab2)
End With
MatchFound = 0
For i = 1 To LastRowTab2
'checking whether value in tab2 column b is same as tab1 column g
Tab2ColumnB = Trim(Sheets(Tab2).Range("B" & i).Value)
Tab1ColumnG = Trim(Sheets(Tab1).Range("G" & i).Value)
If Tab2ColumnB = Tab1ColumnG Then
Tab2ColumnC = Trim(Sheets(Tab2).Range("C" & i).Value)
Tab2ColumnD = Trim(Sheets(Tab2).Range("D" & i).Value)
Sheets(Tab1).Range("E" & i).Value = Tab2ColumnC
Sheets(Tab1).Range("F" & i).Value = Tab2ColumnD
MatchFound = MatchFound + 1
End If
Next
If MatchFound = 0 Then
MsgBox "No matches found"
ElseIf MatchFound > 0 Then
MsgBox MatchFound & " matches were found."
End If
End Sub
I think you can achieve what you want with simple Excel formulas.
In Shipment Package, type the following into E1 and F1 and then drag formula down:
E1 = VLOOKUP(G1,'Mass Update Steps'!$B$1:$D$20,2,0)
F1 = VLOOKUP(G1,'Mass Update Steps'!$B$1:$D$20,3,0)
NB - you'll need to amend $B$1:$D$20 depending on how much data you have in Mass Update
Finally, this assumes that there is always a match. If not, and you want to get rid of those pesky #N/A values, then update the formuals with ISNA e.g.
E1 = IF(ISNA(VLOOKUP(G1,'Mass Update Steps'!$B$1:$D$4,2,0)),"",VLOOKUP(G1,'Mass Update Steps'!$B$1:$D$4,2,0))
Hope that helps.

Resources