MisterSrosis
New Member
- Joined
- Jul 30, 2014
- Messages
- 12
Code:
Dim ct As Long
Dim ct2 As Long
Dim wkb As Workbook
Dim fileN As Variant
Dim sht As Worksheet
Dim c As Range
Dim arrCnt As Long
Dim cAddressArr() As Variant
Dim conf As Variant
Dim columnBeingAnalyzed As Integer
Dim ce As Range
Dim filterS As String
Dim filterS2 As String
conf = MsgBox("Do you think you know 2 general facts about your specific component? Example: When describing a resistor we consider resistance value, what type of resistor it is (power,variable,ceramic)", vbYesNo)
arrCnt = 0
If conf = vbYes Then
filterS = Application.InputBox("Enter category that your sepcific component belongs to(Ex: resistor,the categories a resistor can belong to are power, variable, high voltage etc.):")
filterS2 = Application.InputBox("Enter any further Identification/value/ID number of Component")
For ct = 0 To UBound(Results)
fileN = "labInventory" & "\" & Results(ct)
Set wkb = Workbooks.Open(fileN)
Set sht = wkb.Sheets(Results(ct + 1))
sht.Activate
For Each c In sht.UsedRange.Cells
If InStr(c.Value, filterS) > 0 Then
'checking the column in which the first filterstring was found for the 2nd filterString
columnBeingAnalyzed = c.Column
For Each ce In sht.UsedRange.Columns(columnBeingAnalyzed)
If InStr(c.Value, filterS2) > 0 Then
arrCnt = arrCnt + 1
cAddressArr(arrCnt) = c.Address + "" + sht.Name + "" + wkb.Name
End If
Next ce
End If
Next c
ActiveWorkbook.Close (False)
ct = ct + 2
Else
filterS2 = Application.InputBox("Enter any further Identification/value/ID number of Component")
For ct = 0 To UBound(Results)
arrCnt = 0
fileN = "labInventory" & "\" & Results(ct)
Set wkb = Workbooks.Open(fileN)
Set sht = wkb.Sheets(Results(ct + 1))
sht.Activate
For Each c In sht.UsedRange.Cells
If InStr(c.Value, filterS2) > 0 Then
arrCnt = arrCnt + 1
cAddressArr(arrCnt) = c.Address + "" + sht.Name + "" + wkb.Name
End If
Next c
ActiveWorkbook.Close (False)
ct = ct + 2
End If
FilterResultsEvenFurther = cAddressArr
End Function