My problem is that the values the code found don't apper in the choisen workbook. Any idea?
Thanks
Kenguru
I have the following code:
Sub main()
strFile = "Excel Workbooks (*.xls),*.xls,All Files (*.*),*.*"
strFile = Application.GetOpenFilename(strFile, 1, _
"Select Workbook ", , False)
If Len(strFile) < 6 Then Exit Sub ' no file selected
Set wb = Workbooks.Open(strFile, True, True)
compare
wb.Close False ' close workbook without saving changes
Set wb = Nothing
End Sub
Sub compare()
Dim sheet As Integer
Dim keresendo_szo As String
sheet = 3
j = 4
megtalalt = False
For i = 6 To 102
keresendo_szo = Trim(wb.Sheets(sheet).Cells(i, j))
For k = 6 To 1700
If Trim(wb.Sheets(2).Cells(k, j)) = keresendo_szo And megtalalt = False Then
wb.Sheets(sheet).Cells(i, j + 2) = Trim(wb.Sheets(2).Cells(k, j + 2))
megtalalt = True
wb.Sheets(sheet).Cells(i, j + 6) = "ok"
End If
Next k
If megtalalt = False Then
wb.Sheets(sheet).Cells(i, j + 6) = "Not ok"
End If
megtalalt = False
Next i
End Sub
Thanks
Kenguru
I have the following code:
Sub main()
strFile = "Excel Workbooks (*.xls),*.xls,All Files (*.*),*.*"
strFile = Application.GetOpenFilename(strFile, 1, _
"Select Workbook ", , False)
If Len(strFile) < 6 Then Exit Sub ' no file selected
Set wb = Workbooks.Open(strFile, True, True)
compare
wb.Close False ' close workbook without saving changes
Set wb = Nothing
End Sub
Sub compare()
Dim sheet As Integer
Dim keresendo_szo As String
sheet = 3
j = 4
megtalalt = False
For i = 6 To 102
keresendo_szo = Trim(wb.Sheets(sheet).Cells(i, j))
For k = 6 To 1700
If Trim(wb.Sheets(2).Cells(k, j)) = keresendo_szo And megtalalt = False Then
wb.Sheets(sheet).Cells(i, j + 2) = Trim(wb.Sheets(2).Cells(k, j + 2))
megtalalt = True
wb.Sheets(sheet).Cells(i, j + 6) = "ok"
End If
Next k
If megtalalt = False Then
wb.Sheets(sheet).Cells(i, j + 6) = "Not ok"
End If
megtalalt = False
Next i
End Sub