I try to match the data in two worksheets. I have a primary key and one column of assigned data in each of the worksheets. The goal is to match the assigned data without showing the primary key in a third worksheet.I'm also open for other solution ideas. Thank you very much!
In the debug mode the line:
lgfindRow = ThisWorkbook.Sheets("Labeltexte").Columns(1).Find(strPIN, lookat:=xlWhole, LookIn:=xlValues, MatchCase:=True).row
is highlighted.
The complete sub:
Sub MatchData()
Dim datasheet As Worksheet
Dim lgCount As Long
Dim intlastRow As Integer
Dim strPIN As String
Dim intcolumn As Integer
Dim intcheck As Integer
Dim intrange As Integer
Dim lgfindRow As Long
Dim intcancel As Integer
Set datasheet = ThisWorkbook.Worksheets("Produktdaten")
intlastRow = ThisWorkbook.Sheets("Artikelnummern").UsedRange.SpecialCells(xlCellTypeLastCell).row
For lgCount = 1 To intlastRow
intcolumn = 3
intcheck = 1
intcancel = 0
strPIN = ThisWorkbook.Sheets("Artikelnummern").Cells(lgCount, 1).Value
datasheet.Cells(lgCount, 1).Value = strPIN
datasheet.Cells(lgCount, 2).Value = ThisWorkbook.Sheets("Artikelnummern").Cells(lgCount, 2).Value
lgfindRow = ThisWorkbook.Sheets("Labeltexte").Columns(1).Find(strPIN, lookat:=xlWhole, LookIn:=xlValues, MatchCase:=True).row**
Do Until ThisWorkbook.Sheets("Labeltexte").Cells(lgfindRow + intcheck, 1).Value <> "" Or intcancel = 10
intcheck = intcheck + 1
intcancel = intcancel + 1
Loop
For intrange = 0 To intcheck - 1
datasheet.Cells(lgCount, intcolumn).Value = ThisWorkbook.Sheets("Labeltexte").Cells(lgfindRow + intrange, 2).Value
intcolumn = intcolumn + 1
Next
Next
End Sub