I put this code behind my Validate button. When I test, nothing happens. I feel I may have this incorrect.
Here is my code:
Private Sub CommandButton1_Click()
Dim i As Integer
Dim z As Integer
z = TextBox1.Value
Cells(1, 49).EntireColumn.Clear
For i = 2 To z
mat_name = Cells(i, 1).Value
mat_type = Cells(i, 13).Value
equip_type = Cells(i, 14).Value
Module = Cells(i, 29).Value
If mat_name = "" Then
Cells(i, 1).Interior.ColorIndex = 3
Cells(i, 49).Value = Cells(i, 49).Value + "Material Name is required "
ElseIf Len(mat_name) > 80 Then
Cells(i, 1).Interior.ColorIndex = 6
Cells(i, 49).Value = Cells(i, 49).Value + "Material Name is longer than 80 characters "
Else
Cells(i, 1).Interior.ColorIndex = xlNone
End If
If mat_type = "" Then
Cells(i, 13).Interior.ColorIndex = 3
Cells(i, 49).Value = Cells(i, 49).Value + " Material Type is required, "
ElseIf ((mat_type <> "Case Cart"

And (mat_type <> "Drug"

And (mat_type <> "Equipment"

And (mat_type <> "Implant"

And (mat_type <> "Instrument"

And (mat_type <> "Supply"

And (mat_type <> "Tray"

) Then
Cells(i, 13).Interior.ColorIndex = 6
Cells(i, 49).Value = Cells(i, 49).Value + " Material Type can only be Case Cart,Drug, Equipment,Implant,Instrument,Supply, Tray "
Else
Cells(i, 13).Interior.ColorIndex = xlNone
End If
If mat_type = "Equipment" And ((equip_type <> "Basic"

And (equip_type <> "Cautery"

And (equip_type <> "Laser"

And (equip_type <> "Tourniquet"

) Then
Cells(i, 14).Interior.ColorIndex = 3
Cells(i, 49).Value = Cells(i, 49).Value + " Equipment is required, "
Else
Cells(i, 14).Interior.ColorIndex = xlNone
End If
If Module = "" Then
Cells(i, 29).Interior.ColorIndex = 3
Cells(i, 49).Value = Cells(i, 49).Value + "A module is required "
Else
Cells(i, 29).Interior.ColorIndex = xlNone
End If
Next
End Sub
Sub GetDiffs()
Dim lRow As Long, cols As Integer, i As Integer, refArr As Variant, CompArr As Variant
Dim refSht As Worksheet, compSht As Worksheet, incr As Long
Set refSht = Sheets("Manufacturer"

Set compSht = Sheets("Materials"

Application.ScreenUpdating = False
lRow = refSht.UsedRange.Rows.Count
refSht.Select
refArr = refSht.Range(Cells(1, 1), Cells(lRow, 1)) 'Loads Column A
compSht.Select
CompArr = compSht.Range(Cells(1, 28), Cells(lRow, 28)) 'Loads column AB on sheet2
For x = 1 To UBound(refArr)
If refArr(x, 1) <> CompArr(x, 1) Then
With compSht
.Cells(x, 49).Value = "No Match"
.Cells(x, 28).Interior.ColorIndex = 3
End With
Else
End If
Next
End Sub
I have tried stepping through the code. It errors with a Subscript out of range at the first step into...
thanks