I have a list of part numbers as shown below, each one has a range start and end value which needs to replace the *** in the part number.
I am trying to identify the range start and end value, look them up on the range list on sheet2 (RangeTable) and then concatenate that with the part number individually, so for each part number in column A, a range value defined in column B and C will be concatenated on sheet3 (PartNumbers).
The code is not identifying the Range Start and End value and is creating a part number for all values on the Range Table.
Sub CompilePartNums()
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Dim WS3 As Worksheet
Dim LR1 As Long
Dim LR2 As Long
Dim LR3 As Long
Dim Ctr1 As Long
Dim Ctr2 As Long
Set WS1 = Worksheets("Tabelle1")
Set WS2 = Worksheets("RangeTable")
Set WS3 = Worksheets("PartNumbers")
With WS1
LR1 = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With WS2
LR2 = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
LR3 = 2
For Ctr1 = 2 To LR1
For Ctr2 = 2 To LR2
Select Case WS2.Cells(Ctr2, 1)
Case WS1.Cells(Ctr1, 2) To WS1.Cells(Ctr1, 3)
WS3.Cells(LR3, 1) = replace(WS1.Cells(Ctr1, 1), "***", WS2.Cells(Ctr2, 1))
LR3 = LR3 + 1
End Select
Next
Next
End Sub
Sheet1 (Tabelle1) Looks like this and continues down to ROW1210
Sheet2 (RangeTable) looks like this, the values in this need to stay in this order which are not sequential
Sheet3 (PartNumbers) is the results that are output, it should stop at 390 however it continues thru all the RangeTable values.
xxxx***xxx
(or maybe justxxxx***
- it probably doesn't matter), and another list of part numbers (in the same format) in column A of the RangeTable sheet. In columns B & C of that sheet you have some values (let's say 10 in B and 22 in C). You want to generate records in column A of the PartNumbers sheet, one row sayingxxxx10xxx
, the next sayingxxxx11xxx
, etc, and then you want to do the same with the next part number on the Tabelle1 sheet? – YowE3Ka range value defined in column B and C
, but none of the screenshots have anything in column B and C. – YowE3K