VLookUp Error Handling Needed

G

Guest

I have a Vlookup table.
I’m looping through a column of letters.
The value of cell F2 is inserted into named range “_Inâ€.
Named range “_Out†returns what that letter gets converted to.
If there is not a match from the Vlookup, I’m not sure how to handle the
error.
The desired outcome is whatever the value not matching up (varA) should
remain as is.
Sincerely,
Arturo


Sub Convert()
Dim myRange As Range
Dim rO As Integer
Dim coL As Integer
Dim LoopCount_C As Integer
Dim LoopCount_R As Integer
Dim VarA As Variant
Dim VarB As Variant


''' Rows("1:9").Delete Shift:=xlUp
Range("A1").Select
Set myRange = ActiveCell.CurrentRegion
rO = myRange.Rows.Count - 1
coL = myRange.Columns.Count
Range("F2").Select
For LoopCount_C = 1 To coL
For LoopCount_R = 1 To rO
VarA = ActiveCell.Value
Range("_In").Value = VarA
VarB = Range("_Out").Value

'Error Handling Needed.
'If no match is found then
'ActiveCell.Value = VarA

ActiveCell.Value = VarB
ActiveCell.Offset(1, 0).Select
Next
ActiveCell.Offset(-rO, 1).Select
Next

End Sub
 
G

Guest

For LoopCount_R = 1 To rO
VarA = ActiveCell.Value
Range("_In").Value = VarA
VarB = Range("_Out").Value
if not iserror(varB) then
ActiveCell.Value = VarB
End if
ActiveCell.Offset(1, 0).Select
Next

The activecell already has the value of varA, so no action is required if
there is no replacement value.
 
G

Guest

THANK You Tom!

Tom Ogilvy said:
For LoopCount_R = 1 To rO
VarA = ActiveCell.Value
Range("_In").Value = VarA
VarB = Range("_Out").Value
if not iserror(varB) then
ActiveCell.Value = VarB
End if
ActiveCell.Offset(1, 0).Select
Next

The activecell already has the value of varA, so no action is required if
there is no replacement value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top