Thread: Match using VBA
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
fi.or.jp.de fi.or.jp.de is offline
external usenet poster
 
Posts: 93
Default Match using VBA

I want to match from sheet2 to Sheet1.

Awaiting for your reply



On Jul 7, 8:40*am, GS wrote:
Where is the next cell in relation to the data cell in sheet1?

If ToRight:

Sheet1:
* A1: *IN134566
* A2: *IN455544

Sheet2:
* A1: *IN00000134566
* A2: *IN00000455544

Sub MatchValues()
* Dim lLastRow As Long, j As Long, k As Long
* Dim vData1 As Variant, vData2 As Variant

* lLastRow = Sheets("Sheet1").Cells(Sheets("Sheet1").Rows.Count ,
1).End(xlUp).Row
* vData1 = Sheets("Sheet1").Range("$A$1:$A$" & lLastRow)
* lLastRow = Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count ,
1).End(xlUp).Row
* vData2 = Sheets("Sheet2").Range("$A$1:$A$" & lLastRow)

* For j = LBound(vData1) To UBound(vData1)
* * For k = LBound(vData2) To UBound(vData2)
* * * If InStr(1, vData2(k, 1), Mid$(vData1(j, 1), 3)) 0 Then
* * * * Sheets("Sheet1").Cells(j, 2) = "Yes": Exit For
* * * End If
* * Next 'k
* Next 'j
End Sub

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc