All,
I am having an issue pulling a specific number back from an array of data.
The thought is to have a "lot value" column and then "Sample" and "Reject" columns. Based on the entry into the userform textbox I want it to select the data based on the lot size entered into a different textbox on the userform. Sample spreadsheet image below;
I am struggling to pull back the correct data and am a little lost. Any help would be great.
Code below;
I am having an issue pulling a specific number back from an array of data.
The thought is to have a "lot value" column and then "Sample" and "Reject" columns. Based on the entry into the userform textbox I want it to select the data based on the lot size entered into a different textbox on the userform. Sample spreadsheet image below;
I am struggling to pull back the correct data and am a little lost. Any help would be great.
Code below;
VBA Code:
Worksheets("RI Codes").Activate
If LotSizeTB.Value = 1 Then
SampleTB.Value = 1
RejectTB.Value = 1
Else
Col = Range("" & Left(RICodeTB, 1) & "" & 1).Column
With Worksheets("RI Codes").ListObjects(1).DataBodyRange
X = Evaluate("=MATCH(TRUE," & .Columns(1).Address & ">=" & Val(LotSizeTB) & ",0)")
If RICodeTB = "P1" Then
SampleTB.Value = 1
RejectTB.Value = 0
ElseIf Not IsError(X) Then
SampleTB = .Cells(X, Left(RICodeTB, 1) + 2)
'SampleTB = .Cells(X, Col - 9) 'sample size
RejectTB = .Cells(X, Right(RICodeTB, 1) + 2) 'reject qty
Else
MsgBox "SAMPLE SIZE IS NOT WITHIN TABLE PARAMETERS", vbInformation, ""
End If
End With
End If