Thread: vlookup in VBA
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Nicawette Nicawette is offline
external usenet poster
 
Posts: 27
Default vlookup in VBA

Hi

I have in Cell A1 a string of chars like AABBCC
I have a correspondence table in sheet3

A - B
B- C
C - D

I have made this function to return a modified string (from AABBCC to
BBCCDD) but it returns me #VALUE? someone can help me?

Public Function Encode(InputString As String) As String
Dim intLen As Integer
Dim intCount As Integer
Set myRng = Worksheets("sheet3").Range("G1:H36")

intLen = Len(InputString)
For intCount = 1 To intLen
Encode = Encode & _
Application.VLookup(Mid(InputString, intCount, 1), myRng,
2, False)
Next
End Function

thank you